在 app.vue 組件里面的編寫
<template>
<div id="app">
<!-- 路由占位符 -->
<router-view v-if="isRouterAlive"></router-view>
</div>
</template>
<script>
export default {
provide () {
return {
reload: this.reload
}
},
data () {
return {
isRouterAlive: true
}
},
methods: {
reload () {
this.isRouterAlive = false
this.$nextTick(function () {
this.isRouterAlive = true
})
}
}
}
</script>
<style lang="less" scoped>
</style>
在需要用到的組件里面引用
export default {
inject: ['reload'],
// 監(jiān)聽對話框的確定按鈕
editCategoryDialogConfirm () {
let _this = this
_this.reload()
})
}
}