【发布时间】:2020-03-24 00:28:29
【问题描述】:
您好,我正在为这个过滤器不工作而苦苦挣扎:
export default {
props: {
participants: Array,
},
methods: {
filterUsersByCostCenter() {
this.participants.filter(function (participant) {
return (participant.cost_center == 2);
});
}
}
}
</script>
这是参与者的样子:
participants = [
[0] => {
'name': 'Luca',
'surname': 'Rossi',
'cost_center': 1
}
[1] => {
'name': 'Mario',
'surname': 'Rossi',
'cost_center': 2
}
]
我希望只获得第二个索引作为结果但不起作用
【问题讨论】:
-
您的
filterUsersByCostCenter不会返回(或分配)任何内容,添加“不起作用”以外的描述实际上会暗示这一点。
标签: javascript laravel vue.js