<!--miniprogram/custom-tab-bar/index.wxml-->
<view class="tab-bar">
<view class="tab-bar-border"></view>
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<!-- <image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image> -->
<el-icon icon="{{item.icon}}" size="48" style="color: {{selected === index ? selectedColor : color}}"></el-icon>
<view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
</view>
</view>
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#409EFF",
list: [{
pagePath: "/views/home/index",
icon:"el-icon-s-home",
text: "首页"
}, {
pagePath: "/views/user/index",
icon:"el-icon-user-solid",
text: "我的"
}]
},
attached() {
},
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({url})
this.setData({
selected: data.index
})
}
}
})
界面是成功跳转了,我下面的tabbar没有变化,刚点击的是高亮后,闪烁了一下就又变成了首页高亮,然后再次点击我的。我的高亮了。需要点击两次。第二次就感觉没有跳转了
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。