vue解决刷新页面出现白屏的情况

在App.vue中

<template>
  <div id="app">  
    <router-view v-if='isRouterAlive'/>
  </div>
</template>
<script>
	export default{
		provide(){
			return{
				reload:this.reload
			}
		},
		data(){
			return{
				isRouterAlive:true
			}
		},
		methods:{
			reload(){
				this.isRouterAlive=false
				this.$nextTick(function(){
					this.isRouterAlive=true
				})
			}
		}
	}
</script>

需要刷新的页面中加入

export default {
    inject:['reload'],
    data:{}
}
// 触发的方法中调用
methods:{
    this.reload()
}

猜你喜欢

转载自blog.csdn.net/weixin_43906597/article/details/115209891