1、如果出现以下报错:引入
Echarts因为在Dom还没加载的时候,option 获取元素,
echarts.init(document.queryselect(’#dom’))就开始检测dom,并尝试去获取它,但是在vue中引用echarts的中,在模板dom还没加载的时候echarts.init() 就已经开始执行,所以会报错 Initialize failed: invalid dom
2、解决办法:mounted勾子函数中写入this.$nextTick()回调函数,然后再加载 this.initHistogramChart();
mounted() {
this.$nextTick(()=>{
this.initHistogramChart();
})
},