vue cli 项目 父组件数据变化后 子组件重新加载,更新数据

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>


 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值