首页 > 其他 > 详细

VUE面刷新

时间:2019-10-21 17:56:55      阅读:60      评论:0      收藏:0      [点我收藏+]

 1.这种方法页面会一瞬间的白屏

this.$router.go(0)

2.这种也是一样,画面一闪

location.reload()

3.搭配provide、inject使用

首先在主页面 app.vue

设置:

 <keep-alive include="GjTable">
      <router-view v-if="isRouterAlive"></router-view
  ></keep-alive>

设置:script

export default {

 provide () {
    return {
      reload: this.reload
    },
  data () {
    return {
      isRouterAlive: true
    }
  },

 methods: {
 
    reload () {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    }
  }
}

在需要刷新的页面导入

inject: [reload],

调用刷新:  

// 此页面加了缓存需要重新加载数据 
 this.getgjtype(vue)  
 this.reload() // 刷新页面 

 

VUE面刷新

原文:https://www.cnblogs.com/ouyangkai/p/11714957.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!