内容
vue中局部刷新组件,可以使用provide/inject方法,在App.vue中添加刷新方法,路由初始状态是显示的
1、在template中添加的内容
<template>
<router-view v-if="isRouterAlive"></router-view>
</template>
2、在script中添加的内容
<script>
export default {
provide () {
return {
reload: this.reload
}
},
data () {
return {
isRouterAlive: true
}
},
methods: {
reload () {
this.isRouterAlive = false
this.$nextTick(function () {
this.isRouterAlive = true
})
}
}
}
</script>
3、在需要的地方调用
export default {
inject: ['reload'],
data () {
...
},
methods: {
select(){
this.reload();
}
}
</script>
697

被折叠的 条评论
为什么被折叠?



