1、从A跳转到B A页面
uni.navigateTo({
url: '/pages/content/contentPage?other=' +encodeURIComponent(JSON.stringify(other)) +'&others=' + encodeURIComponent(JSON.stringify(others)) + '&ids=' + ids
})
2、B页面接参
onLoad(options) {
this.id = options.ids
this.other =
JSON.parse(decodeURIComponent(this.$tool.encodeContent(options.other)))
this.other.content_kind = true
this.others =
JSON.parse(decodeURIComponent(this.$tool.encodeContent(options.others)))
},
其中this.$tool.encodeContent 方法是 参数中有复杂的对象用的
//传复杂参替换
encodeContent(key) {
const encodeArr = [{
code: '%',
encode: '%25'
}, {
code: '?',
encode: '%3F'
}, {
code: '#',
encode: '%23'
}, {
code: '&',
encode: '%26'
}, {
code: '=',
encode: '%3D'
}];
return key.replace(/[%?#&=]/g, ($, index, str) => {
for (const k of encodeArr) {
if (k.code === $) {
return k.encode;
}
}
});
},