自定义tabBar:
<!--custom-tab-bar/index.wxml-->
<view class="tab-bar">
<view class="tab-bar-border">
<view class="tab-bar-item" bindtap="xiaokaotap">
<image class="cover-image" src="{{index_img_1}}" mode="widthFix" />
<text class="cover-view" style="color:{{text_color_db}}">校考</text>
</view>
<view class="tab-bar-item" bindtap="liankaotap">
<image class="cover-image" src="{{index_img_3}}" mode="widthFix" />
<text class="cover-view" style="color:{{text_color_70}}">联考</text>
</view>
</view>
</view>
引入页面后,在引入页面的js中定义数据和图片:
data: {
index_img_1: "/images/xiaokao_707070.png",
index_img_3: "/images/liankao_dbdbdb.png",
text_color_70: "#dbdbdb",
text_color_db: "#707070",
},
liankaotap:function(){
wx.navigateTo({
url: '/pages/liankao/liankao',
})
},
xiaokaotap:function(){
}
可是,引入的页面没有显示图标图片,点击按钮,出现提示:
Component "pages/liankao/liankao" does not have a method "liankaotap" to handle event "tap".
(anonymous) @ WASubContext.js?t=wechat&s=1680533060139&v=2.30.2:1
he @ WASubContext.js?t=wechat&s=1680533060139&v=2.30.2:1
fe @ WASubContext.js?t=wechat&s=1680533060139&v=2.30.2:1
(anonymous) @ WASubContext.js?t=wechat&s=1680533060139&v=2.30.2:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1680533060139&v=2.30.2:1
emit @ WAServiceMainContext.js?t=wechat&s=1680533060139&v=2.30.2:1
dispatch @ WAServiceMainContext.js?t=wechat&s=1680533060139&v=2.30.2:1
cb @ WAServiceMainContext.js?t=wechat&s=1680533060139&v=2.30.2:1
a @ VM9 asdebug.js:10
c @ VM9 asdebug.js:10
(anonymous) @ VM9 asdebug.js:1
f @ VM9 asdebug.js:1
g @ VM9 asdebug.js:1
(anonymous) @ VM9 asdebug.js:1
_ws.onmessage @ VM9 asdebug.js:1
明明已经在wxml中定义了“liankaotap”,js里面也定义了这个动作。
为啥总是提示我没有定义呢?