var chess = document.getElementById("chess");
var context = chess.getContext("2d");
context.strokeStyle = "#999";
var bg = new Image();
bg.src="images/back.png";
bg.onload=function(){
context.drawImage = (bg,0,0,450,450);
chessContext();
}
var chessContext=function(){
for(var i = 0; i < 15; i++){
context.moveTo(15+i*30,15);
context.lineTo(15+i*30,435);
context.stroke();
context.moveTo(15,15+i*30);
context.lineTo(435,15+i*30);
context.stroke();
}
}
context.drawImage = (bg,0,0,450,450);
这行代码错了,应该是 context.drawImage(bg,0,0,450,450);
同求。。。我也是的
src找不到图片,文件结构是一模一样的!