怎么不能顯示呢
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html; charset=utf-8">
<title>test</title>
<script?type="text/javascript"?src="js/canval.js">
window.onload=function{
? var dom=document.getElementById("clock");
? var ctx=dom.getContext("2d");
? ? ? ? beginPath();
? ? ? ? ctx.moveTo(200,200);
? ? ? ? ctx.lineTo(500,500);
? ? ? ? ctx.lineTo(200,500);
? ? ? ? ctx.lineWidth=10;
? ? ? ? ctx.stroke.style="yellow"
? ? ? ? ctx.stroke();
}
</script>
<style?type="text/css">
? ?#clock{
? ? border:1px solid red;
? ? width:800px;
? ? height: 800px;
? ? margin: 100px auto;
? ? margin-left:100px;
? ?}
? ?
</style>
</head>
<body>
<canvas?id="clock"></canvas>
</body>
</html>
怎么不能顯示呢
2017-03-02
js那不用寫src了,因為你這個腳本本身就是內(nèi)嵌在網(wǎng)頁中,不是鏈接的外部文件。