vue实现刷新当前页面 (用于重新加载数据)
原文:https://blog.csdn.net/yufengaotian/article/details/81238792App.vue<template><div id="app"><router-view v-if="isRouterAlive"></router-view></div></...
·
原文:https://blog.csdn.net/yufengaotian/article/details/81238792
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
})
}
},
components:{
}
}
</script>
子页面
<script>
export default {
inject:['reload'],
methods:{
clear(){
this.reload()
}
}
</script>
更多推荐
已为社区贡献5条内容
所有评论(0)