我在这段代码的最后一块中不断出现类型错误,这是画布3.任何想法?我假设某处有拼写错误但无法找到它。除非有些事情被错误地命名为......
// Canvas 1
var canvas1 = document.getElementById("canvas1");
var context = canvas1.getContext("2d");
photo = document.getElementById("red");
function drawImage() {
context.drawImage(photo, 0, 0);
}
window.addEventListener("load", drawImage, false);
// Canvas 2
var canvas2 = document.getElementById("canvas2");
var context2 = canvas2.getContext("2d");
context2.fillStyle = "darkRed";
context2.fillRect(0, 2, 800, 500);
context2.moveTo(0, 0);
context2.lineTo(400, 300);
// Canvas 3
var canvas3 = document.getElementById("canvas3");
var context3 = canvas3.getContext("2d");
photo3 = document.getElementById("red2");
function drawImageTile() {
for (var x = 0; x < 6; x++) {
for (var y =0; y < 6; y++ ) {
context3.drawImageTile(photo3, x * 100, y * 75, 100, 75);
}
}
}
window.addEventListener("load", drawImageTile, false);
答案 0 :(得分:1)
canvas.getContext没有drawImageTile()方法,你的意思是drawImage()?
context.drawImage(img,x,y);