亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序自定義漸變的tabbar導(dǎo)航欄功能

 更新時間:2022年09月14日 09:44:08   作者:平凡的不平凡  
這篇文章主要介紹了微信小程序自定義漸變的tabbar導(dǎo)航欄,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

做為自己的一個小筆記,以免后面再用到

1,在需要自定義的界面的json文件中加入下面代碼 "navigationStyle": "custom" ,隱藏系統(tǒng)導(dǎo)航欄

{
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#000",
"navigationBarTextStyle": "white",
"backgroundTextStyle": "dark",
"usingComponents": {
},
"navigationStyle": "custom"
}

2,創(chuàng)建components 文件,為了方便復(fù)用
js 文件內(nèi)容:

const app = getApp()
Component({
properties: {
defaultData: {
type: Object,
value: {
title: "默認(rèn)標(biāo)題"
},
observer: function (newVal, oldVal) {}
},
topOpacity: {
type: Number,
value: {
topOpacity: 0,
}
}
},
data: {
navBarHeight: app.globalData.navBarHeight,
menuRight: app.globalData.menuRight,
menuTop: app.globalData.menuTop,
menuHeight: app.globalData.menuHeight,
},
attached: function () {
},
methods: {
}
})

wxml文件內(nèi)容:

<!-- 自定義頂部欄 -->
<view class="nav-bar" style="height:{{navBarHeight}}px;">
<view class="nav-barback" style="height:{{navBarHeight}}px;opacity:{{topOpacity}}"></view>
<input class="search" placeholder="輸入關(guān)鍵詞!" style="height:{{menuHeight}}px; min-height:{{menuHeight}}px; line-height:{{menuHeight}}px; left:{{menuRight}}px; top:{{menuTop}}px;"></input>
</view>
<!-- 占位,高度與頂部欄一樣 -->
<view style="height:{{navBarHeight}}px;"></view>

wxss文件內(nèi)容:

.nav-bar {
position: fixed;
width: 100%;
top: 0;
color: rgb(255, 255, 255);
/* background: rgb(255, 255, 255); */
z-index: 10000;
}
.nav-barback{
background-color: #FFD52F;
width: 100%;
position: relative;
top: 0;
z-index: 10001;
}
.nav-bar .search {
width: 60%;
color: #333;
font-size: 14px;
background: #fff;
position: absolute;
border-radius: 50px;
background: rgb(255, 255, 255);
padding-left: 14px;
z-index: 10002;
}

在需要使用的界面使用方法

1,在json中引入該components,

2,wxml中

<navigationBar default-data="{{defaultData}}" topOpacity="{{topOpacityFloat}}"></navigationBar>

3,js中,這個標(biāo)題看需求后面可以替換搜索欄

defaultData: {
  title: "我的主頁", // 導(dǎo)航欄標(biāo)題
},

4,該方法是監(jiān)聽當(dāng)前界面滾動的回調(diào),上滑時,自定義的背景色透明度會從0一直到1,達(dá)成漸變效果

onPageScroll(t){
let topOpacity = t.scrollTop / 100
console.log('topOpacity',t.scrollTop,topOpacity);
if (t.scrollTop < 10) {
topOpacity = 0
} else if (topOpacity >= 1) {
topOpacity = 1
}
this.setData({
topOpacityFloat: topOpacity
})
},

到此這篇關(guān)于微信小程序自定義漸變的tabbar導(dǎo)航欄的文章就介紹到這了,更多相關(guān)小程序自定義導(dǎo)航欄內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論