方法一: location.reload();
方法二: this.$router.go(0);
方法三: provide() 与 inject 结合;
  1. 在App.vue中
<template>
    <router-view v-if="isRouterAlive"/>
</template>

<script>
export default {
  name: 'App',
  provide () {
    return {
      reload: this.reload
    }
  },
  data () {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function(){
        this.isRouterAlive = true
      })
    }
  }
}
</script>
  1. 在组件中
export default {
  inject: ['reload'],
  methods: {
    refreshPage () {
      this.reload()
    }
  }
}
Logo

前往低代码交流专区

更多推荐