为什么renderDigit 无定义? 求大神解答
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#canvas{
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script src="digit.js"></script>
<script>
let WINDOW_WIDTH=1024;
let WINDOW_HEIGHT= 768;
let RADIUS = 8;
let MARGIN_TOP = 60;
let MARGIN_LEFT = 30;
window.onload = function(){//确定整个页面加载完成 执行
let c2d = document.querySelector("canvas").getContext("2d");
canvas.width = WINDOW_WIDTH;
canvas.height = WINDOW_HEIGHT;
render(c2d) //调用函数
}
function render( c2d ){ //自定义函数
let h = 12;//小时
let m = 34;//分钟
let s = 56;//秒
//renderDight(x, y, num, c2d);//调用函数
renderDigit( MARGIN_LEFT , MARGIN_TOP , parseInt(h/10) ,c2d);
renderDigit( MARGIN_LEFT + 15*(RADIUS+1) , MARGIN_TOP , parseInt(h%10) , c2d );
renderDigit( MARGIN_LEFT + 30*(RADIUS+1) , MARGIN_TOP , 10 , c2d );
renderDigit( MARGIN_LEFT + 39*(RADIUS+1) , MARGIN_TOP , parseInt(m/10) ,c2d);
renderDigit( MARGIN_LEFT + 54*(RADIUS+1) , MARGIN_TOP , parseInt(m%10) ,c2d);
renderDigit( MARGIN_LEFT + 69*(RADIUS+1) , MARGIN_TOP , 10 , c2d);
renderDigit( MARGIN_LEFT + 78*(RADIUS+1) , MARGIN_TOP , parseInt(s/10) , c2d);
renderDigit( MARGIN_LEFT + 93*(RADIUS+1) , MARGIN_TOP , parseInt(s%10) , c2d);
}
function renderDight(x, y, num, c2d){ //自定义函数-绘制时钟
c2d.fillStyle = "red";
for(let i=0; i<digit[num].length; i++){
for(let j=0; j<digit[num][i].length; j++){
if(digit[num][i][j]==1){
c2d.beginPath();
let _x = j*2*(RADIUS+1)+(RADIUS+1);
let _y = i*2*(RADIUS+1)+(RADIUS+1);
c2d.arc(_x, _y, RADIUS, 0, 2*Math.PI);
c2d.closePath();
c2d.fill();
}//end if
}// end for
}//end for
}
</script>
</body>
</html>