当前位置: 代码迷 >> HTML/CSS >> HTML5 canvas strkeStyle属性设置出错,该如何解决
  详细解决方案

HTML5 canvas strkeStyle属性设置出错,该如何解决

热度:153   发布时间:2012-04-05 12:42:40.0
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";
自己对比一下。。看看有什么差别。。变量都不一样。。。