(1)在app.vue
<template>
<router-view v-if="isRouterAlive" />
</template>
<script>
import { defineComponent, ref, nextTick, provide } from 'vue';
export default defineComponent({
setup() {
// 局部组件刷新
const isRouterAlive = ref(true);
const reload = () => {
isRouterAlive.value = false;
nextTick(() => {
isRouterAlive.value = true;
});
};
provide("reload", reload);