Vue 实现刷新

Vue 实现刷新

 

app.vue

 <router-view v-if="isRouterAlive"></router-view>

app.vue

export default {
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    },
}
};

 

使用时 this.reload();

export default {
  inject: ['reload'],
 data() {
    return {}
}

}

 

posted @ 2022-01-06 10:58  Shadow997  阅读(32)  评论(0)    收藏  举报