小程序将数组传到页面的案例:
传递页面:通过JSON.stringify方法将数组转换成字符串后传递,代码:
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);
//将字符串转换成数组还是对象
this.setData({
model: bean
})
},
本文来源:https://www.yuntue.com/post/80142.html | 云服务器网,转载请注明出处!