收藏
回答

为什么我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);
    }
  }
})
回答关注问题邀请回答
收藏
登录 后发表内容