方法一: location.reload();
方法二: this.$router.go(0);
注意:方法一和方法二都会刷新整个页面
方法三: provide() 与 inject 结合;
在父组件(不一定是app.vue,例如含导航菜单的地方也会用route-view):
<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>
在要做刷新处理的子组件中:
export default { inject: ['reload'], methods: { refreshPage () { this.reload() } } }
浙公网安备 33010602011771号