- 为什么我tabbar要点击两次图标才切换呢?
[图片]我在对应的tabbar页面都加入了这个 下面是tabbar对应的js文件 Component({ data: { selected: 0, "color": "#868686", "selectedColor": "#2929C7", "list": [{ "pagePath": "/pages/index/index", "iconPath": "/images/slices/组 780.png", "selectedIconPath": "/images/slices/组 797.png", "text": "监测" }, { "pagePath": "/pages/record/record", "text": "记录", "iconPath": "/images/slices/组 806.png", "selectedIconPath": "/images/slices/reduce.png" }, { "pagePath": "/pages/my/my", "text": "我的", "iconPath": "/images/slices/组件 7 – 13.png", "selectedIconPath": "/images/slices/组件 7 – 15.png" }] }, attached() { }, methods: { switchTab(e) { let that = this const data = e.currentTarget.dataset const url = data.path wx.switchTab({ url }) that.setData({ selected: data.index }) console.log(data.index); } } })
2022-03-03 - 自定义tabbar为什么切换页面时要点击两次才切换图标?
我已经在每个tabbar对应页面加入了这个[图片]也没用,下面是组件的js文件 Component({ data: { selected: 0, "color": "#868686", "selectedColor": "#2929C7", "list": [{ "pagePath": "/pages/index/index", "iconPath": "/images/slices/组 780.png", "selectedIconPath": "/images/slices/组 797.png", "text": "监测" }, { "pagePath": "/pages/record/record", "text": "记录", "iconPath": "/images/slices/组 806.png", "selectedIconPath": "/images/slices/reduce.png" }, { "pagePath": "/pages/my/my", "text": "我的", "iconPath": "/images/slices/组件 7 – 13.png", "selectedIconPath": "/images/slices/组件 7 – 15.png" }] }, attached() { }, methods: { switchTab(e) { let that = this const data = e.currentTarget.dataset const url = data.path wx.switchTab({ url }) that.setData({ selected: data.index }) console.log(data.index); } } })
2022-03-03