全局刷新
window.location.reload();
局部刷新
用于页面分区域后某一区域修改数据后的刷新
父组件
<router-view v-if="isRouterAlive" ></router-view>
export default {
provide() {
return {
reload: this.reload
};
},
data() {
return {
isRouterAlive: true};
},
methods: {
reload() {
this.isRouterAlive = false;
this.$nextTick(function() {
this.isRouterAlive = true;
});
}
}
子组件
通过inject调用
inject: ["reload"],
需要执行的地方直接调用方法
this.reload()