1.Echarts组件的id值不能重复,如果想重复使用同一个组件使可以设置ref=””的值。
<template>
<div id="main1" ref="chartp" style="height: 400px; width: 518px"></div>
</template>
mounted() {
this.myChart = echarts.init(this.$refs.chartp);
this.myChart.setOption(this.option);
}
2.当在父组件使用async/await 方法接收数据后,在子组件中Prop该数据时出现undefined问题的解决。(注意检查传过来数据的格式)
private myChart: any;
@Watch("dataSize", { deep: true ,immediate: true})
public valueChange(val: any) {
this.myChart && this.myChart.setOption(this.option); // 重点
}
3.当父组件需要向子组件传图片时,路径格式不正确会报错,正确格式如下。
url: require("@/assets/icons/research.png")