vue刷新本页面

顶层app.vue页面

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

</script>

要刷新的页面代码

export default {
  inject: ['reload'],
  data() {
    return {
      
    }
  },
     methods: {
        handleReload(){
            this.reload();
        }
    },   
    
}            

就这样,可以愉快的刷新页面了。此刷新并不会改变vuex状态。

原文地址:https://www.cnblogs.com/zhuzeliang/p/8872603.html