一、在App.vue创建自定义刷新方法reload
<template>
<div id="app">
<!-- 1、添加判断是否显示此模块 -->
<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
})
},
},
mounted() {
}
}
</script>
二、在需要刷新的页面引入自定义的刷新方法
export default {
inject: ['reload'],
data() {
},
methods: {
del(){
this.reload()
}
}
}