日期:2014-05-17  浏览次数:20562 次

HTML5 canvas strkeStyle属性设置出错
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
//ctx.strokeStyle = "blue";
cxt.lineWidth=5;
cxt.beginPath();
cxt.moveTo(10,10);
cxt.lineTo(150,50);
cxt.lineTo(10,50);
cxt.stroke();

代码如上,加了注释的那行//ctx.strokeStyle = "blue";就画不出图形来。。

------解决方案--------------------
var cxt=c.getContext("2d");
//ctx.strokeStyle = "blue";
自己对比一下。。看看有什么差别。。变量都不一样。。。