天天看點

vue.js 重新整理頁面

做電商或其他項目的時候在操作資料之後需要更新一下頁面 使用者手動刷體驗不好 整個頁面重新整理太突兀,

在app.vue 完成如下

<router-view  v-wechat-title="$route.meta.title" v-if="isRouterAlive"/>



provide(){
      return{
        reload:this.reload
      }
    },
    data(){
      return{
        isRouterAlive:true,
      }
    },
    methods:{
      reload(){
        this.isRouterAlive = false;
        this.$nextTick(function () {
          this.isRouterAlive = true;
        })
      }
    }
           

在需要使用的頁面 注入依賴

inject:["reload"],
           

使用

this.reload();
           

完成