uniapp之uni.navigateTo路由跳转传参,参数是对象


如何传递一个object类型数据呢?

在网上好了好多中方法,都有个坑,

A页面跳转 
goEdit(item){ var items = item uni.navigateTo({ url:'./editLiaison?items='+ encodeURIComponent(items), }) }

 需要在你的路径后面拼接 ?itmes = 然后

+ encodeURIComponent(items)
B页面接收   
onLoad (option) { const items = decodeURIComponent(option.items); const res = JSON.parse(items) },

  这里注意需要用decodeURIComponent(option.items) 接收 

接收的值是json字符串类型的,需要用JSON.parse(items)转换一下




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM