更新时间:2023-01-04 17:52:38
如果我正确理解了您的问题,那么您重新绘制硬编码画布元素。参数化抽屉,并使用不同的ID两次调用它。根据此模式更改脚本
If I understood you correctly your problem is that you're drawing in a hardcoded canvas element. Parametrise your drawer and call it two times with different id. Change your script according to this pattern
function drawInCanvas(id){
var myCanvas = document.getElementById(id);
myCanvas.width = 50;
myCanvas.height = 40;
// and the rest of the code...
}
drawInCanvas("myCanvas1");
drawInCanvas("myCanvas2");