androidxufeng

微信小程序跳转传参

一般都是传字符串到下一页,如果要想传对象怎么办呢?

我的解决办法是先将对象转换为json字符串然后到下个页面将json字符串,再转化为对象。如下:

let str=JSON.stringify(e.currentTarget.dataset.item);
wx.navigateTo({
url: \'../toMybaby/babyDetail/babyDetail?jsonStr=\'+str,
success: function (res) {
// success
},
fail: function () {
// fail
},
complete: function () {
// complete
}
})
  onLoad:function(options){
    // 生命周期函数--监听页面加载
    let item=JSON.parse(options.jsonStr);
    this.setData({ward:item});
  },

 

分类:

技术点:

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2021-11-22
  • 2021-07-05
  • 2021-12-19
  • 2021-06-05
  • 2022-12-23
  • 2021-12-19
猜你喜欢
  • 2021-12-26
  • 2021-11-10
  • 2022-12-23
  • 2021-12-22
  • 2022-01-16
相关资源
相似解决方案