实现页面刷新不闪烁,同 this.$router.push()
1.app.vue
<template>
<div id="app">
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
export default {
name: "App",
//解决跳转到当前页面不刷新问题
provide() {
return {
reload: this.reload,
};
},
data() {
return {
isRouterAlive: true,
}
},
methods:{
reload() {
this.isRouterAlive = false;
this.$nextTick(() => {
this.isRouterAlive = true;
});
},
}
}
</script>
2.调用刷新的页面
export default {
inject: ["reload"],
methods:{
changeLanguage(item) {
var that = this;
// this.pageLoading();
that.curLang = item.name;
//修改全局语言状态
this.$i18n.locale = item.value;
localStorage.setItem("language", item.value);
this.reload()
}
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。