实现页面刷新不闪动,同 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() } }}