我是 javascript 初学者,并尝试执行一些 if else 语句。基本上你可以在第二行看到我自己的代码!直到第七行。但dreamwaever 将其标记为始终为红色!所以我做错了什么
this.toDataURL = function() {
if this.path == []
{
document.getElementById("canvascontent").value = "Oh yeah";
}
else
{
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.width = innerWidth;
canvas.height = innerHeight;
ctx.drawImage(layer0, 0, 0);
ctx.drawImage(layer1, 0, 0);
ctx.drawImage(layer2, 0, 0);
var url = canvas.toDataURL('image/png');
document.getElementById("canvascontent").value = url;
}
};