微信小程序重寫(xiě)tabbar底部導(dǎo)航,供大家參考,具體內(nèi)容如下

在寶應(yīng)等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作按需網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),成都營(yíng)銷網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站建設(shè)公司,寶應(yīng)網(wǎng)站建設(shè)費(fèi)用合理。
1.app.js代碼如下:
editTabBar: function() {
var e = this.globalData.tabbar, a = getCurrentPages(), t = a[a.length - 1], s = t.__route__;
0 != s.indexOf("/") && (s = "/" + s);
for (var n in e.list) e.list[n].selected = !1, e.list[n].pagePath == s && (e.list[n].selected = !0);
t.setData({
tabbar: e
});
},
tabBar: {
color: "#123",
selectedColor: "#1ba9ba",
borderStyle: "#1ba9ba",
backgroundColor: "#fff",
list: [ {
pagePath: "/we7/pages/index/index",
iconPath: "/we7/resource/icon/home.png",
selectedIconPath: "/we7/resource/icon/homeselect.png",
text: "首頁(yè)"
}, {
pagePath: "/we7/pages/user/index/index",
iconPath: "/we7/resource/icon/user.png",
selectedIconPath: "/we7/resource/icon/userselect.png",
text: "我的"
} ]
},
globalData: {
userInfo: null,
tabbar: {
color: "#333",
selectedColor: "#d0501f",
backgroundColor: "#ffffff",
borderStyle: "#d5d5d5",
list: [ {
pagePath: "/pages/seller/gzt",
text: "工作臺(tái)",
iconPath: "/pages/images/gzt@3x.png",
selectedIconPath: "/pages/images/gztxz@3x.png",
selected: !0
}, {
pagePath: "/pages/seller/cp/cplb",
text: "商品",
iconPath: "/pages/images/dbdc.png",
selectedIconPath: "/pages/images/dbdcxz.png",
selected: !1
},
position: "bottom"
}
},
template.wxml
<template name="tabbar">
<view class="tabbar_box" >
<navigator class="tabbar_nav" openType="redirect" url="{{item.pagePath}}" wx:for="{{tabbar.list}}" wx:key="index">
<image class="tabbar_icon" src="{{item.selected?item.selectedIconPath:item.iconPath}}"></image>
<text>{{item.text}}</text>
</navigator>
</view>
</template>
3.template.wxss
.tabbar_box {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-pack: distribute;
justify-content: space-around;
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
height: 100rpx;
border-top: 0.5rpx solid #d5d5d5;
}
.tabbar_nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
font-size: 25rpx;
height: 100%;
}
.tabbar_icon {
width: 40rpx;
height: 40rpx;
}
在需要用的頁(yè)面(wxml)添加如下代碼
<import src="template.wxml"></import>
<template is="tabbar" data="{{tabbar:tabbar}}"></template>
在需要的樣式(wxss)添加如下代碼
@import "template.wxss";
在需要的js頁(yè)面添加如下代碼:
var dsq, app = getApp();添加在頂部
tabbar: {},在data中添加
app.editTabBar();在onLoad中添加
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
網(wǎng)頁(yè)題目:微信小程序tabbar底部導(dǎo)航
文章URL:http://www.chinadenli.net/article40/iehcho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、、手機(jī)網(wǎng)站建設(shè)、虛擬主機(jī)、電子商務(wù)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)