在canvas标签中定义width、height跟在style中定义width、height是不同的。canvas标签的width和height是画布实际宽度和高度,就是在这个上面绘制图形。style的width和height是canvas画布在浏览器中被渲染的高度和宽度。如果canvas的width和height没指定或值不正确,就被设置成默认值(300px,height:150px)。