vue项目实现重新加载本页面
App.vue:
<tempalte> <router-view v-if="isRouterAlive" /> </tempalte> export default defineComponent({ provide () { return { reload: this.reload } } data () { retrun { isRouterAlive: true } }, methods: { reload () { this.isRouterAlive = false this.$nextTick(() => { this.isRouterAlive = true }) } } })
页面使用:
<el-button @click="reload">刷新页面</el-button> export default { inject: ['reload'] }