Vue第 39 篇,The image argument is a canvas element with a width or height of 0(Uncaught DOMException:)

一. 问题

项目报错,请看:

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

图例:


二. 原因

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

V

在CanvasRenderingContext2D上执行'drawImage'失败:image参数是一个宽度或高度为0的canvas元素。

这种报错,一般出现在使用canvas页面时出现。例如,在使用Echarts或地图的时候。顾名思义,元素没有设置宽高。


三. 解决方法

这里直接给需要加载应用的容器,设置宽高,就可以解决。请看

<div id="doctor" style="height: 100%; width: 100%;"></div>

创作不易,感觉有用,就一键三连,感谢(●'◡'●)

猜你喜欢

转载自blog.csdn.net/weixin_65793170/article/details/129615720#comments_34425689