Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导入数据报错 - Uncaught TypeError: Converting circular structure to JSON #296

Open
aboutdever opened this issue Mar 5, 2025 · 2 comments

Comments

@aboutdever
Copy link

aboutdever commented Mar 5, 2025

异常

Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'children' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    --- property 'parent' closes the circle
    at JSON.stringify (<anonymous>)
    at D.rn [as refresh] (MindElixir.js:1484:29)

复现

// 版本 - mind-elixir@^3.0.0
const data = {
    nodeData: {
        id: 'root',
        topic: 'root',
        children: [
            {
                id: 'sub1',
                topic: 'sub1',
                children: [
                    {
                        id: 'sub2',
                        topic: 'sub2',
                    },
                ],
            },
        ],
    },
}
mind.init(data)
// 此处报错
mind.refresh(data)
@aboutdever
Copy link
Author

初始化导入时移除 mind.refresh(data) 即可修复此问题

@SSShooter
Copy link
Owner

同一个对象的话其实是不用传data的,出现这个问题的原因是初始化的时候把parent字段插进去了导致循环,我也在考虑初始化之前深拷贝一次

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants