记录一个使用echats问题,要展示一个echarts图表,父组件请求后台数据传递到echarts组件,echarts图表显示不出来
首先父组件请求后台数据进行传递
//consLable是请求到的数据
<relation-chart :consLable="consLable"></relation-chart>
子组件将consLable接收,接收后会发现子组件并没有获取到数据
props: ['consLable'],
此刻需要进行watch监听,监听之后加载图表echarts,记得把mounted钩子函数里面加载图表的方法注释,不让你会发现图表一直加载不出来。
watch:{
consLable: {
deep: true,
handler(newValue, oldValue) {
this.chartConsLable = newValue
//加载图表函数
this.initpie()
)
}
}
}