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']  
}

 

posted @ 2022-07-22 10:23  氧化成风  阅读(2044)  评论(0编辑  收藏  举报