vue 刷新不闪烁

1,443 阅读1分钟

1、修改APP.vue

<template>
    <div id="app">
        <router-view v-if="isRouterAlive"></router-view>
    </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'],
………………

3、直接调用this.reload()即可