VUE element-ui 表格筛选filter-method方法,适用于数组,嵌套对象
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
·
希望大家指正
针对这种情况,第一栏是新老校区都有的情况

筛选的数据是这样的,classTimePosition是表格的一个prop绑定的属性
classTimePosition: [{
campus:'new',
timePosition:[{
time:'1',
weekD: '周三',
position:'bw221',
},{
time:'2',
weekD: '周一',
position:'bx211',
}],
},{
campus:'old',
timePosition:[{
time:'3',
weekD: '周五',
position:'bs227',
}],
}
],
//表头筛选
filterHandler(value, row, column){ //筛选选项的value,一行row对象,column一列的属性值
const property = column['property']; // column['property']值为属性名·
// console.log(JSON.stringify(column));
//筛选数据中[{campus: '',..... }]这种类型数据
if(Array.isArray(row[property])){ //行中该属性是数组
var arr = false;
for(var i in row[property]){
//每次的arr为上一次和这一次结果的或,效果就是如果数据出现新老校区都有的情况,筛选到时候新老校区都会显示这条数据
arr = (row[property][i].campus === value)||arr;
}
return arr;
}
//
else if(row[property] instanceof Object){//属性值是对象
if(row[property].isInstituteRc!=undefined)
return row[property].isInstituteRc === value;
}
else{ //普通属性值
return row[property] === value;
}
},
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
1 年前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)