直接开始:
在你所要刷新的 中改写:
<template>
<router-view v-if="isRouterAlive"/>
</template>
<script>
export default {
data () {
return {
isRouterAlive: true
}
},
provide() {
return {
reload: this.reload; //this.reload方法注入 到reload参数中,从子组件获取
}
},
methods: {
reload () {
this.isRouterAlive = false;
this.$nextTick(() => (this.isRouterAlive = true));
}
}
}
</script>
子组件:
{
inject: ['reload'] //获取组件传递过来的reload方法
}
methods:{
goOnReload() {
this.reload(); //重新加载页面
},
}