更新部分页面但是不刷新整个页面

2019-06-21  本文已影响0人  李昂李三光

app.vue

<template>
  <div id="app">
    <router-view v-if="isRouterAlive"/>
  </div>
</template>
<script type="text/javascript">
    export default {
        name:"app",
        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'],
  methods:{
    fun(){
      ...
      this.reload()
    }
  }
}
上一篇 下一篇

猜你喜欢

热点阅读