首次进入 是正常显示 进入 一个详情页面再进入 另一个tabbar 页面 就不见了 目前测试阶 iphone16上出现这个情况;
但是在首次加载后tabbar页面切换到另一个tabbar页面也是正常的;
意思是只要tabbar 页面没有被加载过 从其他非 tabbar也跳转过来tabbar栏都不会显示。(奇怪的是我登录后跳转的第一个tabbar页面又是正常显示的)
import config from '../config'
var app = getApp()
Component({
data: {
tabShowStyle: '',
tabBarShow: true,
maskVisible: false,
isShow: false,
selected: 0,
color: "rgba(206, 206, 206, 1)",
selectedColor: "rgba(255, 93, 102, 1)",
list: [{
pagePath: "/pages/index/index",
iconPath: config.fileURL + "new_xf/img/tabBar/home.png",
selectedIconPath: config.fileURL + "new_xf/img/tabBar/home_active.png",
text: "首页",
textKey:'index',
className: 'tab-bar-item',
hidden: false
},
{
pagePath: "/pages/house/house",
iconPath: config.fileURL + "new_xf/img/tabBar/house.png",
selectedIconPath: config.fileURL + "new_xf/img/tabBar/house_active.png",
text: "房源",
className: 'tab-bar-item',
info: 0,
hidden: false,
textKey: 'code1'
},
{
pagePath: "/pages/car/car",
iconPath: config.fileURL + "new_xf/img/tabBar/car.png",
selectedIconPath: config.fileURL + "new_xf/img/tabBar/car_active.png",
text: "车位",
className: 'tab-bar-item',
info: 0,
hidden: false,
textKey: 'code2'
},
{
pagePath: "/pages/intention/intention",
iconPath: config.fileURL + "new_xf/img/tabBar/yxd.png",
selectedIconPath: config.fileURL + "new_xf/img/tabBar/yxd_active.png",
text: "意向单",
className: 'tab-bar-item',
hidden: false
},
],
loginShow: false,
joinShow: false,
baseImage: app.globalData.baseImage,
imagesLoaded: false,
tabData:{}
},
lifetimes: {
async attached() {
},
},
properties: {
update:{
type:Number,
value:0
}
},
observers:{
update: function (to) {
this.updateTabTextFromGlobalData()
}
},
methods: {
switchTab(e) {
if(this.data.maskVisible) return
const data = e.currentTarget.dataset
let path = data.path
let CATE = 0;
if (path.includes('car')) {
CATE = 2;
path = app.observeCarType()
}
if (path.includes('house')) {
CATE = 1;
path = app.observeRoomType()
}
if(CATE !== 0) app.globalData.CATE = CATE;
app.globalDialog.hide()
let pages = getCurrentPages();
let page = pages[pages.length - 1];
if(page.data.pageId === "plane" && path === "/pages/plane/plane" && page.data.CATE !== CATE){
page.doRenovateCATE()
}else{
wx.switchTab({ url: path })
}
},
showMask() {
if (!this.data.maskVisible) {
this.setData({ maskVisible: true })
}
},
hideMask() {
if (this.data.maskVisible) {
this.setData({ maskVisible: false })
}
},
onMaskTap() {
this.hideMask()
},
updateTabTextFromGlobalData() {
const { code1, code2 ,settlementDocIds,projectInfo,tabData} = app.globalData
const list = this.data.list.map(item => {
const newItem = { ...item }
if (item.textKey === 'code1') {
newItem.text = code1 ? code1 : newItem.text
newItem.hidden = !( projectInfo.cate_room == 1)
} else if (item.textKey === 'code2') {
newItem.text = code2 ? code2 : newItem.text
newItem.hidden = !(projectInfo.cate_car == 1)
}
return newItem
})
this.setData({ list,tabData })
},
}
})
<!--miniprogram/custom-tab-bar/index.wxml-->
<view class="tab-bar" style="{{tabShowStyle}}">
<view class="zw_box"></view>
<view class="tabbar_content">
<view wx:for="{{list}}" wx:key="index" wx:if="{{!item.hidden}}" class="tab-bar-item {{item.className + index}}" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<image
src="{{item.iconPath}}"
class="cover_image {{selected === index ? 'hide' : 'show'}}"
mode="aspectFit"
></image>
<image
src="{{item.selectedIconPath}}"
class="select_cover_img {{selected === index ? 'show' : 'hide'}}"
mode="aspectFit"
></image>
<view wx:if="{{selected !== index}}" style="color: {{selected === index ? selectedColor : color}}" class="cover_view">{{item.text}}</view>
</view>
</view>
</view>
需要自定义 tabbar,也就是自己实现一个,别用官方的 tabbar 组件就可以了