学习文章:https://www.jb51.net/article/233809.htm
App.vue
<template>
<div id="app">
<router-view v-if="isShow"/>
</div>
</template>
<script>
export default {
name: 'App',
provide(){
return{
reload:this.reload
}
},
data(){
return{
isShow:true
}
},
methods:{
reload(){
this.isShow=false;
this.$nextTick(()=>{
this.isShow=true
})
}
}
}
</script>
页面刷新
<script>
import { pagenum } from '@/utils/public'
export default {
name: 'usergroup',
inject:['reload'], ***//需要引入***
data() {
return {}
},
methods: {
// 点击刷新
saveInfo: function() {
var _this = this;
setTimeout(function(){
_this.reload()
},500)
}
},
},
created() {
var _this = this;
this.$nextTick(function() {
})
},
}
</script>
局部刷新
定义一个变量 isReloadData,并将该变量绑定到需要刷新的标签上 v-if=" isReloadData "