vue弹框echarts报错Cannot read property 'getAttribute' of undefined
主要的问题是echars图标还没出来,数据现出来了(已经解决)<script>import echarts from 'echarts'export default {methods: {drawPieChart(){let echa = this.$refs.echa;...
·
主要的问题是echars图标还没出来,数据现出来了(已经解决)
<script>
import echarts from 'echarts'
export default {
methods: {
drawPieChart(){
let echa = this.$refs.echa;
this.mychartPie = echarts.init(echa);
this.mychartPie.setOption({
title: {
text: '问题:'+this.editaForm.question,
x: 'center'
},
xAxis: {
type: 'category',
data: ['一','二','三']//x轴名称
},
yAxis: {
type: 'value'
},
series: [{
data: [22,22,22],//y轴数量
type: 'bar'
}]
});
}
},
updated: function () {
this.drawPieChart();
},
mounted:function () {
this.$nextTick(function () {
this.drawPieChart();
});
}
}
</script>
解决方法:
<div style="background-color:#000;">
不需要挂载到updated
updated: function () {
this.drawPieChart();
},
直接把这个写到数据请求的方法中:
this.$nextTick(function () {
this.drawPieChart();
});
</div>
更多推荐
已为社区贡献4条内容
所有评论(0)