开发者社区> seajean> 正文

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

简介: 在进行千牛QAP插件开发的时候,有时会遇到 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时,那么就会触发Converting circular structor to JSON 的报错。

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

解决方法

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

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
解决Angular里的报错:ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError()
解决Angular里的报错:ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError()
215 0
Angular tsconfig.json 文件里的 paths 用途
Angular tsconfig.json 文件里的 paths 用途
45 0
Angular 服务器端渲染应用的一个错误消息 type ReferenceError - localStorage is not defined
在 Angular 应用开发中,我们在 TypeScript 代码里调用 localStorage.
63 0
关于 Angular 应用 tsconfig.json 中的 target 属性
关于 Angular 应用 tsconfig.json 中的 target 属性
66 0
关于 Angular 应用 tsconfig.json 中的 lib 属性
关于 Angular 应用 tsconfig.json 中的 lib 属性
35 0
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
59 0
typescript32-ts中的typeof
typescript32-ts中的typeof
35 0
vue:typescript 提示 Object is possibly null || Object is possibly null: 对象可能是null
vue:typescript 提示 Object is possibly null || Object is possibly null: 对象可能是null
214 0
Angular tsconfig.json 文件里的 paths 用法和 scoped module 定义
Angular tsconfig.json 文件里的 paths 用法和 scoped module 定义
84 0
+关注
seajean
多年前端交互设计经验,目前任职于阿里,定期更新前端文章,欢迎关注...
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Semantic Search--Fast Results from Large,Foreign Language Corpora
立即下载
Towards A Fault-Tolerant Speaker Verification System: A Regularization Approach To Reduce The Condition Number
立即下载
低代码开发师(初级)实战教程
立即下载