错误说明指的是对象存在循环引用,在将对象进行json序列化的时候就会报错。
var obj = {
a: "foo",
};
// undefined
obj;
//{a: "foo"}
obj.b = obj;
// {a: "foo", b: {…}}
JSON.stringify(obj);
/*
VM205:1 Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
--- property 'b' closes the circle
at JSON.stringify (<anonymous>)
at <anonymous>:1:6
*/```
网友评论