vue 点击父组件,刷新子组件

一 、背景

编辑页面, 有个新增, 有个历史记录, 

但是历史记录是引用的子组件, 

所以需要添加之后对子组件的值进行刷新

二、解决方法

<template>
  <div class="pageContainer">
    <el-button type="primary" @click="handleCreate">
      创建
    </el-button>
    <Child :key="timer"></Child>
  </div>
</template>
import Child from "@/components/child";
components: {
    Child 
  },
  data() {
    return {
          timer:null
        }
      },
  methods: {
    handleCreate() {
       this.timer = new Date().getTime();
      // 也可以处理其他事件
    },
}

有用请点赞,养成良好习惯!

疑问、交流、鼓励请留言!

猜你喜欢

转载自blog.csdn.net/libusi001/article/details/127355732
今日推荐