Uncaught TypeError: Converting circular structure to JSON


报错原因

执行JSON.stringify(obj)时 检测到obj 对象有递归引用 (对象的属性值引用了自身)

// 问题代码 -- 注意这里有互相引用的问题
this.param = this.contract[this.index]
this.param.list = this.contract

解决方法

赋值时使用 JSON.parse(JSON.stringify()) 来切断数据之间的相互引用

// 修改后的代码
this.param = JSON.parse(JSON.stringify(this.contract[this.index]))
this.param.list = JSON.parse(JSON.stringify(this.contract))


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM