<template>
  <div>
    <Search :searchData="searchData" @search="handleSearch" />
    <!-- 其他内容 -->
  </div>
</template>
<script>
import Search from './Search.vue';

export default {
  data() {
    return {
      searchData: ''
    };
  },
  components: {
    Search
  },
  methods: {
    handleSearch(data) {
      this.searchData = data;
    }
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.searchData = '';
    });
  },
  beforeRouteUpdate(to, from, next) {
    this.searchData = '';
    next();
  }
};
</script>
Vue 组件数据清空:如何清除父组件中的搜索数据

原文地址: http://www.cveoy.top/t/topic/qvdm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录