HTML基本问题
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="circular.css"></link>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.moveTo(10,10);
cxt.lineTo(150,50);
cxt.lintTo(10,50);
cxt.stroke();
</script>
</head>
<body>
<canvas id="myCanvas" ></canvas>
</body>
</html>
运行有错。var c=null 帮忙看一下原因。
[解决办法]
页面还没加载你就调用。。当然有错了。。把JS放在下面
[解决办法]
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="circular.css"></link>
</head>
<body>
<canvas id="myCanvas" ></canvas><script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.moveTo(10,10);
cxt.lineTo(150,50);
cxt.lintTo(10,50);
cxt.stroke();
</script>
</body>
</html>
---------------------------
脚本放下面
[解决办法]