var Window_Width = 1024; var window_Height = 768; var Radius = 8; window.onload = function(){ var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); canvas.width = Window_Width; canvas.height = window_Height; render(context); } function render(){ var hours = 12; var minutes = 34; var seconds = 56; renderDigit(0,0,parseInt(hours/10),cxt); } function renderDigit(x,y,num,cxt){ cxt.fillStyle = "blue"; for(var i=0;i<digit[num].lenght;i++){ for(var j=0;j<digit[num][i].lenght;j++){ if(digit[num][i] == 1){ cxt.beginPath(); cxt.art(x+(Radius+1)+2*(Radius+1),y+(Radius+1)+2*(Radius+1),Radius,0,2*Math.PI); cxt.closePath(); cst.fill(); } } } }
为什么我的没显示?F12说renderDigit(0,0,parseInt(hours/10),cxt);的cxt有问题
function render(cxt){ //render函数头里面忘写形参cxt了
var hours = 12;
var minutes = 34;
var seconds = 56;
renderDigit(0,0,parseInt(hours/10),cxt);
}