微信小程序傳遞參數(字符串、數組、對象)



【轉自燕歆波】感謝!
//經過提供的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
      })    
  },

原文:http://blog.csdn.net/yanxiaosa/article/details/73643066this

相關文章
相關標籤/搜索