canvas为什么不能显示图片
varimg=newImage();if(isWin){img.src="lib/pass.png";}else{img.src="lib/fail.png";}cons...
var img = new Image();
if (isWin) {
img.src = "lib/pass.png";
}else{
img.src = "lib/fail.png";
}
console.log(game.ctx,img);
game.ctx.drawImage(img,100,150)
打印 结果:CanvasRenderingContext2D {canvas: canvas#map, globalAlpha: 1, globalCompositeOperation: "source-over", filter: "none", imageSmoothingEnabled: true…}
<img src="lib/fail.png">
展开
if (isWin) {
img.src = "lib/pass.png";
}else{
img.src = "lib/fail.png";
}
console.log(game.ctx,img);
game.ctx.drawImage(img,100,150)
打印 结果:CanvasRenderingContext2D {canvas: canvas#map, globalAlpha: 1, globalCompositeOperation: "source-over", filter: "none", imageSmoothingEnabled: true…}
<img src="lib/fail.png">
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询