Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be

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.
在这里插入图片描述
github isssue上有类似的问题:https://github.com/apache/echarts/issues/4569

解决办法:

初始化的时候无法获取 dom 的 clientWidth 和 clientHeight,新版本支持初始化的时候指定高宽,http://echarts.baidu.com/api.html#echarts.init

this.$echarts.init(
        ele,
        theme,
        {
    
    
          height: this.height,
          width: this.width,
        },
      )

猜你喜欢

转载自blog.csdn.net/weixin_41886421/article/details/129850296