天天看点

WEEX 报错 TypeError: Converting circular structor to JSON 的解决方法

在进行千牛qap插件开发的时候,有时会遇到 typeerror: converting circular structor to json,并且看不到报错位置,对新手可能会造成疑惑。

weex(rax)的js代码运行在js环境,跟native端通信的时候只能用字符串,如果js跟native通讯的时候,传送了不能转换为字符串的对象,那么就会报错,比如function,weex的console.log方法最终是调用了natvie的log方法,如果给这个方法的参数包含函数或者不合法的json时,那么就会触发<code>converting circular structor to json</code> 的报错。

另外weex 的console.group方法不支持, 加入了console.group在debugger模式的时候不报错,但是在native下就会报错,原因是debugger下,用的是chrome的console方法,所以不会有问题。

检查页面所有console.log的方法,是不是传入了函数或者其他非法字符。删掉以后一般就会正常。

继续阅读