1.在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>
2.在子组件里面引用
inject:['reload'],
3.在需要的地方调用:
this.reload();
vue页面刷新:
最新推荐文章于 2023-10-20 16:31:35 发布