报错说没有这个函数,,可我打印出来是有值的啊,反复检查没写错呀
来源:3-5 编程练习
qq_陌_45
2018-06-12 18:08:50
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>canvas</title> <style> canvas{background-color:lightpink;} </style> </head> <body> <canvas id="canvas" width="600" height="600"> 您的浏览器不支持canvas </canvas> <script> var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.moveTo(300,50); ctx.lineTo(150,300); ctx.strokeStyle('red'); ctx.stroke(); </script> </body> </html>
2回答
qq_陌_45
提问者
2018-06-12
解决了ctx.strokeStyle="red";
好帮手慕夭夭
2018-06-12
代码中设置strokeStyle是要有等号哦 ,如下修改:
完善一下吧 ,祝学习愉快 !
相似问题