### [小程序怎样在页面传递对象数组?](https://www.prosaas.cn/article/16650) **Published:** 2020-06-11T05:55:39 **Author:** 5201314 **Excerpt:** 小程序怎样在页面传递对象数组?小程序在页面传递对象数组的方法:传递对象 传递数组 总结,向下一级页面传递对象或… **![](https://img.php.cn/upload/article/000/000/052/5ee1c5ef35123706.jpg)** **小程序怎样在页面传递对象数组?** **小程序在页面传递对象数组的方法:** 传递对象 // 通过JSON.stringify(obj) 方法将对象转化为字符串进行传递// 跳至结算页/\*\* \* 向下一级页面传递对象参数 \*/ buyAction: function(e) { var model = JSON.stringify(e.currentTarget.dataset.obj); wx.navigateTo({ url: '../detail/detail?model=' + model, }) }在下个页面接收//在下个页面的onload中获取, onLoad: function (options) { var model = options.obj; console.log(options.obj) this.setData({ model:model }) }, 传递数组 /\*\* \* 向下一级页面传递对象参数 \*/ buyAction: function(e) { var model = JSON.stringify(selected\_list); wx.navigateTo({ url: '../detail/detail?model=' + model, }) }在下个页面接收/\*\* \* 生命周期函数--监听页面加载 \*/ onLoad: function (options) { // 先将字符串转化为数组 var list = JSON.parse(options.selected\_list) console.log(list) }, 总结,向下一级页面传递对象或者数组的方式是相同的; 先将要传递的参数通过JSON.stringify(obj)方法转化为字符串,再在下级页面onLoad()的options中,将传递的参数再转化为对象或者数组,就可以正常使用了。 推荐教程:《小程序》 以上就是小程序怎样在页面传递对象数组?的详细内容,更多请关注知企PROSAAS其它相关文章! **Tags:** json, 字符串, 对象 **Categories:** 后端开发 ---