页面跳转传递整个对象用JSON.stringify()
const orderDetail = JSON.stringify(this.orderDetail)
uni.navigateTo({
url: `/mall/order-refund/order-refund?orderDetail=` + orderDetail,
})
接收
onLoad(options) {
const data=JSON.parse(options.orderDetail);
},
原因:若对象的参数或数组的元素中遇到地址,地址中包括?、&这些特殊符号时,对象/数组先要通过JSON.stringify转化为字符串再通过encodeURIComponent编码,接收时,先通过decodeURIComponent解码再通过JSON.parse转换为JSON格式的对象/数
const orderDetail = JSON.stringify(this.orderDetail)
uni.navigateTo({
url: `/mall/order-refund/order-refund?orderDetail=` + encodeURIComponent(orderDetail),
})
接收
onLoad(options) {
const data=JSON.parse(decodeURIComponent(options.orderDetail));
},