报错截图
问题
虽然在class
中设置了width
`height`,但是控制台还是发出了警告
上网一查,发现有很多网友也出现了类似的问题,在github
中提了个issue
github isssue
上有类似的问题:https://github.com/apache/echarts/issues/4569
解决办法
初始化的时候无法获取 dom
的 clientWidth
和 clientHeight
,新版本支持初始化的时候指定高宽,http://echarts.baidu.com/api.html#echarts.init
// 当echarts被封装成一个组件时,height和width作为props传入
const myChart = this.$echarts.init(
ele,
theme,
{
height: this.height,
width: this.width,
},
)