admin管理员组

文章数量:1568722

报错内容:

vue.esm.js:5105 [Vue warn]: Error in nextTick: "TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'VueComponent'
    |     property '_scope' -> object with constructor 'EffectScope'
    |     property 'effects' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Watcher'
    --- property 'vm' closes the circle" 

这个错误其实是因为被JSON转化的对象里的子项存在循环引用,JSON转化时其实也是一个深度拷贝的过程,但是存在循环引用的对象,JSON拷贝转化时会失败,解决方案不止一种,这里讲下我使用的方案circular-json。

// 安装插件包:
npm install -S circular-json    

// 在项目中引用:
import CircularJSON from 'circular-json'

// JSON格式转化:
CircularJSON.stringify(存在循环引用的数组、对象)

本文标签: 报错convertingcircularStructureTypeError