
百度小程序的版本1.13.4
1、关于setStorageSync方法,存储JSON数据以后,再取出数据报错的《URI malformed at decodeURIComponent》的BUG;
代码片段:
swan.setStorageSync(‘jsons’, jsons);
var resjsons = swan.getStorageSync(‘jsons’);
console.log(resjsons); //报错《URI malformed at decodeURIComponent》
2、关于,使用setStorageSync => encodeURIComponent(JSON.stringify(res.data)),存储json数据以后,再取出数据,无法转换成json对象,.属性字段名称,取属性的问题;
代码片段:
swan.uploadFile({
…
…
success: function (res) {
var jsons = JSON.stringify( encodeURIComponent(JSON.stringify(res.data)) );
}
})
var resjsons = swan.getStorageSync(‘jsons’);
console.log(resjsons.TrustRank); // 报错 《undefined》
//如果改用代码:
var jsons = JSON.parse(resjsons);
console.log(jsons.TrustRank); //报错 Unexpected token I in JSON
解决方法:
[reply]
给百度小程序邮箱发邮件,亲测会回复:[email protected]
[/reply]
看看是不是有用
解决方法好硬核。。。
看看是不是有用
看看结果,不回复不能看到答案,不清楚有没有用啊
..刚接触 学习下
期待这个结果。。。。。。。。
嗯好的 看到坐着的回复很开心,很激动
来学习一下。
看看是不是有用