发布于 4年前

js报错--Unexpected token o in JSON at position 1

原因:JSON.parse无法识别某些url中的特殊字符

解决方法:
首先 JSON.stringify(对象)
然后encodeURIComponent(str)进行编码
跳转页面后再decodeURIComponent(str)进行解码
最后在JSON.parse(str)转对象

©2020 edoou.com   京ICP备16001874号-3