做很多小程序商品商店的时候遇到switchtab不能带参数。我的解决办法的定义app变量

globalData: {
    userInfo: null,
    classifyId:null,
  }

然后把某个选项卡的id值储存起来

clickclassify:function(e){
    let that = this
    let id = e.currentTarget.dataset.id
    console.log(id)
    app.globalData.classifyId = id
    wx.switchTab({
      url: `/pages/classify/index`,
      success: function (e) {
        var page = getCurrentPages().pop();
        if (page == undefined || page == null) return;
        page.onLoad();
      } 
    })
  },

然后就可以在另外一个也没拿到id值了

onLoad: function (options) {
    app.globalData.classifyId
  },

然后再请求啦。最主要的一点就是切换过去要刷新,就是success这段!!!!!主要!

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-08-07
  • 2021-06-12
  • 2022-02-09
猜你喜欢
  • 2021-06-21
  • 2021-06-13
  • 2021-08-21
  • 2021-10-02
  • 2021-11-20
相关资源
相似解决方案