Vue 刷新组件

参考链接:https://www.cnblogs.com/s313139232/p/9176820.html

利用v-if实现组件刷新

<template>
    <router-view v-if="isRouterAlive"/>
</template>
<script>
export default {
 data () {
   return {
     isRouterAlive: true
   }
 },
 methods: {
   reload () {
     this.isRouterAlive = false
     this.$nextTick(() => (this.isRouterAlive = true))
   }   
 }
}
</script>

然后其它任何想刷新自己的路由页面,都可以这样:
this.reload()

 

posted @ 2022-01-05 14:15  哎哟喂~  阅读(171)  评论(0编辑  收藏  举报