有哪位大神可以帮指出我这个代码哪里有问题吗,就是简单的画个图和填充个矩形,下面是代码,图片是运行结果。(图片和矩形都没画出来)
let i = 0;
const canvas = wx.createCanvas();
const ctx = canvas.getContext("2d");
export default class Main {
constructor() {
ctx.fillStyle = "#ffffff";
this.img = wx.createImage();
this.img.src = "images/bg.jpg";
this.antid = 0;
this.restart();
}
restart(){
ctx.drawImage(this.img,0,0,500,500,0,0,600,600);
ctx.fillRect(0,0,60,90);
if(i++<100){
console.log("一次"+i);
this.antid = window.requestAnimationFrame(()=>this.restart(),canvas);
}
}
}