报错: Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
程序员文章站
2022-07-12 11:30:47
...
问题:在页面接收传递过来的json对象时报错
传参页面:
let invite = {
id:albumID,
unionid,
role
}
wx.navigateTo({
url: `/pages/web/web?id=${id}&isShared=1&invite=${JSON.stringify(invite)}`,
});
接收页面打印参数:
console.log('invite',this.invite);
//console.log('invite',JSON.parse(this.invite));//报错 SyntaxError: Unexpected token u in JSON at position 0
结果为
解决方法:
在接收JSON数据时,使用decodeURI()解码
let {id,role,unionid} = JSON.parse(decodeURI(this.invite));
上一篇: Java 并发 —— 读写锁(ReadWriteLock)
下一篇: flutter报错解决 Error: FormatException: SyntaxError: Unexpected token m in JSON at position 1
推荐阅读
-
vue 报错Error in mounted hook: "SyntaxError: Unexpected token u in JSON at position 0"
-
报错: Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
-
flutter报错解决 Error: FormatException: SyntaxError: Unexpected token m in JSON at position 1
-
JSON字符格式报错:VM40:1 Uncaught SyntaxError: Unexpected token E in JSON at position 0
-
SyntaxError: Unexpected token R in JSON at position 0 报错的解决方法
-
报错 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)的解决方法
-
解决报错:Uncaught SyntaxError: Unexpected token “xxx” in JSON at position 0
-
解决报错信息之:SyntaxError: Unexpected token R in JSON at position 0
-
JS报错解决:SyntaxError: Unexpected token 《 in JSON at position 0
-
报错 Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse