⼩程序⽣成⼆维码之传参(接收的参数乱码该咋解决)
乱码文字生成先说我的案例,我需要的是,扫码进⼊不同的区域展⽰(因此这个就需要进⾏⼆维码路径传参),⼤致思路:接收数据,然后根据所接收的数据进⾏判断,展⽰不同的区域。
路径是这样的:pages/addPage/addPage?location=阿⾥爸爸
因此,我们就需要转译,通过所接收的参数进⾏转译然后得到正确的字符(阿⾥爸爸)
下串代码只做接收并进⾏转译操作
onLoad(option){
this.currentLocation = option.location;
//默认如果没有传输地址就为嘻嘻
if (!this.currentLocation || this.currentLocation === undefined || im() === '') {
this.currentLocation = '嘻嘻';
} else if (this.currentLocation.indexOf('\\u') != -1) {
// UNICODE转中⽂
this.currentLocation = unescape(place(/\\u/g, '%u'));
} else if (this.currentLocation.indexOf('%') != -1) {
// encodeURI 转中⽂
this.currentLocation = decodeURI(this.currentLocation);
}
}