自定义底部导航栏在手机端查看是正常的,但在电脑端微信查看没有显示一下是我的自定义导航栏代码
<view class="{{show ? '' : 'overlay'}}">
</view>
<van-tabbar class="tab-bar" wx:if="{{!hide}}" active="{{ active }}" active-color="#5AC7F4" bind:change="onChange">
<block wx:for="{{ list }}" wx:key="index">
<van-tabbar-item style="display: {{item.bool?'':'none'}}">
<image
slot="icon"
src="{{ item.icon.normal }}"
mode="aspectFit"
style="width: 30px; height: 18px;"
/>
<image
slot="icon-active"
src="{{ item.icon.active }}"
mode="aspectFit"
style="width: 30px; height: 18px;"
/>
{{item.text}}
</van-tabbar-item>
</block>
</van-tabbar>
css
.overlay {
position: fixed;
bottom: 0;
left: 0;
z-index: 9999;
width: 100%;
height: 50px;
background-color: rgba(0, 0, 0, 0.7);
}
js
const app = getApp()
Component({
data: {
active: null,
show: true,
hide: false,
list: [
{
text: '首页',
url: '/pages/health/main/main-page',
icon: {
normal: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_home_n.png ',
active: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_home_s.png'
},
bool:true
},
{
text: '档案',
url: '/pages/arichives/main/archives-page',
icon: {
normal: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_file_n.png',
active: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_file_s.png'
},
bool:true
},
{
text: '发现',
url: '/pages/discover/discover',
icon: {
normal: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_find_n.png',
active: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_find_s.png'
},
bool:true
},
{
text: '我的',
url: '/pages/user/center/user-center',
icon: {
normal: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_mine_n.png',
active: 'https://hmpcloud-static.oss-cn-shenzhen.aliyuncs.com/app/images/tab_mine_s.png'
},
bool:true
}
]
},
methods: {
onChange(event) {
wx.switchTab({
url: this.data.list[event.detail].url
})
},
loading() {
this.setData({show: false})
},
endLoading() {
this.setData({show: true})
},
hide() {
this.setData({
hide: true
})
},
show() {
this.setData({
hide: false
})
},
init() {
const page = getCurrentPages().pop()
let list = this.data.list;
if(app.globalData.userInfo){
list[1].bool = true;
list[2].bool = true;
// if(app.globalData.userInfo.viperId){
// //会员显示
// list[2].bool = true;
// }else{
// //非会员隐藏
// list[2].bool = false;
// }
}else{
list[1].bool = false;
list[2].bool = false;
}
this.setData({
list:list,
active: this.data.list.findIndex(item => item.url === `/${page.route}`)
});
}
}
});
我运行了一下你的代码
你好,麻烦加QQ群:145378303咨询,他们有专门的人员处理。加群时请简单说明加群原因,格式:社区-【具体问题】。