encodeURIComponent进行编码
let str = 'kohePOtjXz3AVIo==';
uni.navigateTo({
url: `../list/list?antiFakeCode=${encodeURIComponent(this.antiFakeCode)}`
})
解码时用decodeURIComponent进行解码
onLoad(options) {
console.log('options', options)
this.antiFakeCode = decodeURIComponent(options.antiFakeCode);
},
如果传的时对象,比如:
let obj = {a:1,b:2};
需要先把对象转为字符串
let data = JSON.stringify(obj);
转换完成后在用encodeURIComponent进行编码
uni.navigateTo({
url: `../list/list?antiFakeCode=${encodeURIComponent(this.data)}`
})
跳转页面后再用decodeURIComponent解码,再用JSON.parse()转为对象
onLoad(options) {
console.log('options', options)
let data= decodeURIComponent(options.data);
let datas = JSON.parse(data);
},