首页 前端知识 控制台报错:[ECharts] Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight.

控制台报错:[ECharts] Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight.

2024-07-01 23:07:59 前端知识 前端哥 842 916 我要收藏

报错信息

[ECharts] Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.

表示获取图表容器的宽度和高度时出现了问题。ECharts 无法正确获取到容器的尺寸,可能是因为容器元素的 clientWidth 和 clientHeight 值为 0

解决方法

1.使用nexTick

	mounted() {
		this.$nextTick(()=>{
			this.renderEchats()
		})
	},

2.使用setTimeout

	mounted() {
		setTimeout(() => {
	           this.renderEchats()
	       }, 500)
	},

dom元素截图

请添加图片描述

转载请注明出处或者链接地址:https://www.qianduange.cn//article/13774.html
标签
评论
发布的文章

读魏书生的心得体会

2024-07-03 14:07:10

jQuery 选择器

2024-05-12 00:05:34

Vue中public/assets目录区别

2024-07-02 23:07:29

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!