1、第一种解决方法
(1) App.vue:
声明reload方法,控制router-view 显示或者隐藏 ;
<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(function () {
this.isRouterAlive = true
})
}
}
}
</script>
(2)在要刷新的Vue页面添加一下代码
页面注入reload 方法,使用时直接调用 this.reload();
(3) 调用reload方法