uni-app页面传递参数
普通页面跳转传递参数
uni.navigateTo({
url: `wifi-qrcode?S=${this.name}&P=${this.password}&T=${this.type}`
});
onLoad(params) {
console.log(params.A);
console.log(params.P);
console.log(params.T);
}
bug现象:
- 部分字符消失 ,例如“+”
- 字符长度有限制,超过部分不见了
解决办法
uni.navigateTo({
url: `wifi-qrcode?S=${encodeURIComponent(JSON.stringify(this.name))}&P=${encodeURIComponent(JSON.stringify(this.password))}&T=${encodeURIComponent(JSON.stringify(this.type))}`
});
onLoad(params) {
const S = JSON.parse(decodeURIComponent(params.S));
const T = JSON.parse(decodeURIComponent(params.T));
const P = JSON.parse(decodeURIComponent(params.P));
console.log(S);
console.log(S);
console.log(S);
}