echarts 报错 ‘getAttribute‘ of null“
在运行Vue项目时出现了上述错误,出现该错误的原因是Echarts的图形容器还未生成就对其进行了初始化所造成的,代码如下:
this.chart = echarts.init(document.getElementById(id))
利用Vue中的ref和$refs 来代替document.getElementById()获取该图形容器对象,代码如下:
this.chart = echarts.init(this.$refs.chartDom)
...
转载
2021-01-29 15:47:49 ·
1855 阅读 ·
1 评论