我遇到了一個小問題。我有:html:<!DOCTYPE html><html><head> <link rel="stylesheet" href="chart.css"> <script type="text/javascript" src="chart.js"></script> <title>Chart</title></head><body> <div id="lifespan-chart"> <div id="lifespan-chart-content"></div> </div></body></html>一切正常,但是當我想在函數中向 html 添加塊時,loadChart我在控制臺中看到一個錯誤:Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child element contains the parent. at Polyline.loadChart. 我應該怎么做才能避免這樣的錯誤?我評論了一個錯誤發生的地方。提前致謝!setSvgEDIT 1 :之前忘記執行了loadChart,我在上面添加了,現在畫好了,但是錯誤仍然存在??梢詥??
新的子元素包含父元素 JS 錯誤
侃侃無極
2022-12-22 16:02:17