如何傳遞一個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)轉換一下