vue路由跳转时组件data数据刷新

由于通过路由跳转到其他组件时,一些钩子函数将失效,所以更新页面数据就会失败。

解决办法:使用计算属性:computed

 computed:{
      getBlog: function() {
        return this.blogs.filter(x=>x.blogUser === this.userName)
      }
    }

以下使用该方法:

 <el-table
        :data="getBlog.filter(data => !search || data.blogName.toLowerCase().includes(search.toLowerCase()))"
        style="width: 100%">

猜你喜欢

转载自www.cnblogs.com/hzh-666/p/12294273.html