html 标签上绑定:key="timer"
vue data 中定义 timer: '',
vue 函数中 需要子组件重新加载时候 重新赋值timer this.timer = new Date().getTime()
<template>
<div class="echarts">
<Chart1 ref="Chart1" :key="timer" :style="{height:height+'px'}" v-if="ChartShow" :ChartData="Chart1Data"></Chart1>
<div v-else class="text" :style="{height:height+'px', lineHeight:height+'px'}">
暂无数据
</div>
</div>
</template>
<script>
const Map = new ArcGIS();
export default {
name: "Dqpg",
components: {
},
data() {
return {
timer: '',
};
},
methods: {
//请求数据时态演变
stybSelectyt(apiId) {
getAction("/statistics/gtkjghModelResult/GPStatistics", {
"apiId": apiId,
"xzqdm": this.xzqdm,
"category": "dtjc_json",
"type": "year"
}).then((res) => {
console.log("时态演变......", res)
if (res.data.length == 0) {
this.$refs.chart2.clear()
return
}
if(res.data.length>0){
this.Chart2Data=res.data
this.ChartShow1=true
this.timer = new Date().getTime()
}else{
this.ChartShow1=false
}
})
},
},
};
</script>