技术&日志

微信小程序对象传参数

//通过提供的JSON.stingify方法,将对象转换成字符串后传递
  click:function(e){
    var model = JSON.stringify(e.currentTarget.dataset.model);
    wx.navigateTo({
      url: '../detail/detail?model=' + model,
    })
  }
//接收
onLoad: function (options) {
    //将字符串转换成对象
    var bean = JSON.parse(options.model);
    if(options.model == null){
      wx.showToast({
        title: '数据为空',
      })
      return;
    }
      this.setData({
          model:bean
      })    
  },

相关资料

微信小程序传递参数

发表评论