-1
我不斷收到標題中的錯誤。我究竟做錯了什麼?我不想使用jquery。我知道有一個簡單的答案,我實際上只是沒有看到它。Uncaught TypeError:無法讀取屬性'getContext'null幫助請求
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas1" width="500px" height="500px">
</canvas>
<script>
var canvas = document.getElementById("#canvas1");
var c = canvas.getContext("2d");
c.beginPath();
c.moveTo(0,0);
c.lineTo(100,100);
c.stroke();
</script>
</body>
</html>
不需要''#。 'getElementById(「#canvas1」);'==>'getElementById(「canvas1」);'' – Tushar