0
点赞
收藏
分享

微信扫一扫

[Vue warn] Error in mount hook “TypeError Cannot read properties of null (reading ‘getAttribute‘)

i奇异 2022-03-11 阅读 108

在vue项目中,使用echarts报一下的错误:

[Vue warn]: Error in mount hook: “TypeError: Cannot read properties of null (reading ‘getAttribute‘)

出现该错误的原因是Echarts的图形容器还未生成就对其进行了初始化,

利用Vue中的ref和$refs 来代替document.getElementById()获取该图形容器对象

<div id="mian" ref="chart" ></div>
 
var myChart = this.$echarts.init(this.$refs.chart);

并且使用this.$nextTick(function () { });

举报

相关推荐

0 条评论