首先,设置selected: null,
Component({
data: {
selected: null,
color: '#9B9B9B',
selectedColor: '#000000',
list: [
{
pagePath: '/pages/cyhh/list',
iconPath: '/assets/mine-false.png',
selectedIconPath: '/assets/mine-true.png',
text: '我的发布',
}
],
},
其次switchTab函数中得selected赋值操作删除(在需要tabbar的页面里,onShow函数已经赋值)
switchTab(e) {
console.log(e)
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({ url })
// this.setData({
// selected: data.index,
// })
},