uni-app使用uni.navigateTo传递对象参数示例代码
作者:Bonsoir777
最近在做微信小程序用的是uniapp开发的,自己记录一下,也和大家分享一下,这篇文章主要给大家介绍了关于uni-app使用uni.navigateTo传递对象参数的相关资料,需要的朋友可以参考下
一、传递一般参数
const index = 1; uni.navigateTo({ url: `../address/address?key=${index}` })
二、传递对象参数
1.传递参数
// 跳转到订单详情页面 toOrder(item) { // console.log(item.hpv_id, 'hpv_id') uni.navigateTo({ url: '../hpvOrder-detail/hpvOrder-detail?key=' + encodeURIComponent(JSON.stringify(item)) }) }
2.接收参数
navigateTo进行页面传递参数,在下一个页面接收数据,一般在在onLoad钩子函数中获取
onLoad(e) { this.detail = JSON.parse(decodeURIComponent(e.key)); console.log(this.detail) }
附:多个对象的传递
index页面传递:
uni.navigateTo({ url: '/pages/setSeal/index?seal=' + encodeURIComponent(JSON.stringify(seal)) + '&cStorageModel' + encodeURIComponent(JSON.stringify(cStorageModel)) });
home页面接收:
onLoad(option){ this.pageModel.sealAuth = JSON.parse(decodeURIComponent(option.sealAuth)); this.pageModel.cStorageModel = JSON.parse(decodeURIComponent(option.cStorageModel)); },
总结
到此这篇关于uni-app使用uni.navigateTo传递对象参数的文章就介绍到这了,更多相关uni.navigateTo传递对象参数内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!