代码拉取完成,页面将自动刷新
<canvas>标签只是图形容器,您必须使用_脚本_来绘制图形。
![](/assets/FireShot Capture 19 - HTML5 Canvas I 菜鸟教程 - http___www.runoob.com_html_html5-canvas.html.png)
<canvas id="canvas" width="360" height="480" ></canvas>
var canvas = document.getElementById("canvas");
//通过getContext方法得到绘图的上下文环境
var context = canvas.getContext("2d");
//使用context进行绘制
context.fillStyle="yellow";
context.fillRect(0,0,100,50)
Tip:不用css修饰默认会得到width=300px,height=150px的绘图区域
canvas.width=600;
canvas.height=400;
if(context){
//绘图
}else{
alert("请使用chrome浏览器")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。