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(function() {
this.isRouterAlive = true;
})
}
}
}
</script>
2、到需要刷新的页面引用
export default {
inject: ["reload"],
data() {
return {
}
},
methods: {
//调用
this.reload()
}
}