function drawChessman(i,j,type){ var img = new Image(); img.onload = function(){ cxt.drawImage(img, w*i-10,w*j-10); //检查是否已经赢了 checkWin(); }; if(type){//是黑子 img.src="b.png"; }else{ img.src="w.png"; } }