天天看点

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();
           

完成