app.vue
<template>
<div id="app">
<router-view v-if="isRouterAlive"/>
</div>
</template>
<script type="text/javascript">
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:{
fun(){
...
this.reload()
}
}
}