1、首先需要修改 App.vue

<template>
  <div>
    <router-view v-if="isRouterAlive" />
  </div>
</template>
 
<script>
export default {
  name: "App",
  provide() {
    return {
      reload: this.reload,
    };
  },
  data() {
    return {
      isRouterAlive: true,
    };
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(() => {
        this.isRouterAlive = true;
      });
    },
  },
};
</script>
 
  1. 到需要刷新的页面进行引用,使用 inject 导入引用 reload,然后直接调用即可
<template>
  <div></div>
</template>
 
<script>
export default {
  inject: ['reload'],
  data() {
    return {},
  },
  created() {
    this.reload();
  },
  methods: {},
}
</script>