vue动态获取数据赋值给echarts图,但是图却没有显示出来
//子组件:
<div class="canvas-wrap" ref="myEchart"></div>
data(){
return(){
option:{
xxxxx//内容省略。。。
},
myEchart:null
}
}
methods:{
init(){
this.option.series[0].data = [
{
value: this.content.orgCount.customerCount,
name: '委托方'
},
{
value: this.content.orgCount.kernelCount,
name: '核心企业'
}
],
this.myEchart = this.$echarts.init(this.$refs.myEchart);
this.myEchart.setOption(this.option,true)
}
},
mounted(){
//this.$nextTick(()=>{
//()
//})
},
watch: {//监听异步数据
content: { // content为父组件传递过来的对象
deep: true,
handler: function(newval,oldval){
this.init()
}
}
}