最近项目做一个tab栏切换,因为切换的组件是同一个组件,只是数据不能组件是通过canvas画图画出来的,所以,每一次变动,我实际上都需要清除这个canvas,否则会造成canvas覆盖的问题
// 清除canvas
clearCanvas() {
const canvas = this.$refs.wheelCanvas;
const ctx = canvas.getContext("2d");
canvas.height = canvas.height;
},
类似的方法
clearCanvas()
{
var cxt=document.getElementById("myCanvas").getContext("2d");
cxt.clearRect(0,0,c.width,c.height);
}
clearCanvas()
{
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#000000";
cxt.beginPath();
cxt.fillRect(0,0,c.width,c.height);
cxt.closePath();
}