zhuzeliang

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状态。

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2021-12-20
  • 2021-08-15
  • 2022-01-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-02
  • 2021-06-15
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案