Invalid div ID; div already has a Diagram associated with it.

var parentDiv = document.getElementById('parentDiv');
var mygoChart = document.getElementById('mygoChart');
parentDiv.removeChild(mygoChart);
var div = document.createElement('div');
div.setAttribute('id','mygoChart')
parentDiv.appendChild(div);
Copy the code

Scene: an edit page with a bar, the first step is to render the Canvas drawing, the second step is to do something else…

Problem: When switching to the second step, use display: None on the parent div of canvas to hide the contents of the first step and display other contents. When we go back to the first step again, the parent div of canvas is display:block, and the canvas is rendered blank.

Solution: When hiding the canvas of the first step, to ensure that the width and height of its parent div remain unchanged, you can hide it by locating it outside the viewable area.