收藏
回答

首次加载小程序条件渲染custom-tab-bar时,首屏tabbar真机异常

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 微信安卓客户端 8.0.61 3.8.9

代码片段是自定义custom-tab-bar/index.wxml中的内容,bug场景是:小米civi手机首次打开小程序,登陆接口调用成功,获取token和userType存入缓存中,使用延时器1秒后跳转具备custom-tab-bar的首页,此时首页的custom-tab-bar不显示。通过首页页面上我的订单按钮,跳转到具备tabbar的订单页面,此时订单页面的custom-tab-bar正常显示。关闭小程序进程后再次打开首页custom-tab-bar正常显示。个人排查后发现,首次加载时wx.getStorageSync("userType")中获取的值为"",是空字符串。再次进入后获取到的userType是"garage_user",后来,尝试存入根目录的app.js文件中的globalData.userType字段中,删除小程序缓存后尝试,再首次加载获取app.globalData.userType仍然是“”空字符串。

<view class="tab-bar" wx:if="{{userType=='supplier_user'}}"> <view data-path="/pages/index/index" data-index="0" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/home.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 首页 </view> </view> <view data-path="/pages/order/order" data-index="1" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/order.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 订单 </view> </view> <view data-path="/pages/inquiry/inquiry" data-index="2" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/inquiry.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 询价 </view> </view> <view data-path="/pages/inquirySheet/inquirySheet" data-index="3" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/cart.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 询价单 </view> </view> <view data-path="/pages/mine/mine" data-index="4" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/mine.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 我的 </view> </view> </view> <view class="tab-bar" wx:if="{{userType=='supplier_user'}}"> <view data-path="/pages/p_order/p_order" data-index="0" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/order.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 订单 </view> </view> <view data-path="/pages/p_shipment/p_shipment" data-index="1" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/shipment.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 发货 </view> </view> <view data-path="/pages/p_mine/p_mine" data-index="2" bindtap="switchTab"> <image class="tab-bar-item-image" src="/assets/bar/mine.png"></image> <view class="tab-bar-item-text" style="color: {{selected === index ? selectedColor : color}}"> 个人中心 </view> </view> </view>
回答关注问题邀请回答
收藏

2 个回答

  • 社区技术运营专员--阳光
    社区技术运营专员--阳光
    2025-07-29

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2025-07-29
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-07-27
    有用
登录 后发表内容