由于通过路由跳转到其他组件时,一些钩子函数将失效,所以更新页面数据就会失败。
解决办法:使用计算属性: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%">