window.onload = function(){
var canvas = document.getElementById("canvas");
canvas.width = 800;
canvas.height = 800;
var cxt=canvas.getContext('2d');
cxt.moveTo(10,10);
cxt.lineTo(100,400);
cxt.lineWidth=3;
cxt.strokeStyle="rgba(0,0,0,0.5)";
cxt.stroke();
}
因为检测的是“context”。。。所以改一下命名就好了
是不是你代码的位置放置的不对啊