尝试了,又报错了 页面【pages/index/index]错误: TypeError: Cannot read property 'getTabBar' of undefined at index.js? [sm]:2 at WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1 at p.runWith (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1) at q (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1) at <anonymous>:8:5 at evaluateRes (index.js:1) at index.js:1 at Object.invoke (index.js:1) at r (index.js:1) at Object.invoke (WAServiceMainContext.js?t=wechat&s=1706507854346&v=3.3.3:1)(env: Windows,mp,1.06.2401020; lib: 3.3.3) TypeError: Cannot read property 'getTabBar' of undefined at index.js? [sm]:2 at WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1 at p.runWith (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1) at q (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1) at <anonymous>:8:5 at evaluateRes (index.js:1) at index.js:1 at Object.invoke (index.js:1) at r (index.js:1) at Object.invoke (WAServiceMainContext.js?t=wechat&s=1706507854346&v=3.3.3:1)(env: Windows,mp,1.06.2401020; lib: 3.3.3)
if (typeof this.getTabBar === 'function' ) { this.getTabBar((tabBar) => { tabBar.setData({ selected: 0 }) }) }
页面【pages/index/index]错误:
TypeError: Cannot read property 'getTabBar' of undefined
at index.js? [sm]:2
at WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1
at p.runWith (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1)
at q (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1)
at <anonymous>:8:5
at evaluateRes (index.js:1)
at index.js:1
at Object.invoke (index.js:1)
at r (index.js:1)
at Object.invoke (WAServiceMainContext.js?t=wechat&s=1706507854346&v=3.3.3:1)(env: Windows,mp,1.06.2401020; lib: 3.3.3)
TypeError: Cannot read property 'getTabBar' of undefined
at index.js? [sm]:2
at WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1
at p.runWith (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1)
at q (WASubContext.js?t=wechat&s=1706507854346&v=3.3.3:1)
at <anonymous>:8:5
at evaluateRes (index.js:1)
at index.js:1
at Object.invoke (index.js:1)
at r (index.js:1)
at Object.invoke (WAServiceMainContext.js?t=wechat&s=1706507854346&v=3.3.3:1)(env: Windows,mp,1.06.2401020; lib: 3.3.3)
<!--custom-tab-bar/index.wxml-->
<view class="tab">
<view class="item" bindtap="switchPage" data-index="0">
<text class="iconfont icon-shouye icon {{selectedIndex == 0 ? 'sclected' : '' }}"></text>
<text class="title {{selectedIndex == 0 ? 'sclected' : '' }}">首页</text>
</view>
<view class="item" bindtap="switchPage" data-index="1">
<text class="iconfont icon-shangpinfenlei icon {{selectedIndex == 1 ? 'sclected' : '' }}"></text>
<text class="title {{selectedIndex == 1 ? 'sclected' : '' }}">商品分类</text>
</view>
<view class="item" bindtap="switchPage" data-index="2">
<text class="iconfont icon-gouwuche icon {{selectedIndex == 2 ? 'sclected' : '' }}"></text>
<text class="title {{selectedIndex == 2 ? 'sclected' : '' }}">购物车</text>
</view>
<view class="item" bindtap="switchPage" data-index="3">
<text class="iconfont icon-wo icon {{selectedIndex == 3 ? 'sclected' : '' }}"></text>
<text class="title {{selectedIndex == 3 ? 'sclected' : '' }}">我</text>
</view>
</view>