1、在页面中写的echarts容器:
<div id="charts-one" class="echart" ref="chartsOne"></div>
在方法里面获取用了document.getElementById("charts-one")
以及this.$refs.chartsOne
然后再init的时候会报错,前一种方式报TypeError: Cannot read property 'getAttribute' of null
后面那种报TypeError: Cannot read property 'getAttribute' of undefined
2、自己尝试解决的办法:
在mounted中用之后的办法 还是不可以,
1、this.$nextTick(()=>{方法)}
2、setTimeout(()=>{
this.dataTotal();
},50)
3、虽然报错但是页面数据还是渲染成功,希望大神解惑,谢谢
你这个问题描述很模糊你应该先打印下
this.$refs['chartsOne']
查看下有没有获取到这个节点 建议相关初始化代码以入mounted
试试