1、修改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>
复制代码
2、需要刷新的页面
export default {
inject:['reload'],
………………
复制代码
3、直接调用this.reload()即可