echarts警告 Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They sho

Error screenshot

insert image description here

question

Although `height` classis set in widththe console, the warning is issued

After checking the Internet, I found that many netizens had similar problems, and a similar problem githubwas mentioned in: https://github.com/apache/echarts/issues/4569issue
github isssue

Solution

The and of cannot be domobtained . The new version supports specifying height and width during initialization. http://echarts.baidu.com/api.html#echarts.initclientWidthclientHeight

// 当echarts被封装成一个组件时,height和width作为props传入
const myChart = this.$echarts.init(
  ele,
  theme,
  {
    
    
    height: this.height,
    width: this.width,
  },
)

Supongo que te gusta

Origin blog.csdn.net/weixin_41886421/article/details/130433973
Recomendado
Clasificación