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

完成

猜你喜欢

转载自blog.csdn.net/weixin_43465244/article/details/84646000