我有一个搜索输入,用于过滤表中显示的用户数组。该表包括分页,因此我使用 .slice 来让 10 个用户在每页的表上显示。出于某种原因,如果我在第 1 页上,搜索过滤会起作用(猜测是因为第 1 页上没有切片?);转到另一个页面后,过滤停止工作,这与 .slice 有关,因为如果我删除 .slice 代码,它就可以工作。任何想法这是为什么?有些东西我在这里没有看到..
tableData() {
return this.users
.filter(
(user) =>
user.firstName.toLowerCase().includes(this.search.toLowerCase()) ||
user.lastName.toLowerCase().includes(this.search.toLowerCase()) ||
user.email.toLowerCase().includes(this.search.toLowerCase()),
)
.slice(this.perPage * (this.currentPage - 1), this.perPage * this.currentPage);
},
这是因为您的结果现在在第一页或之前的某个地方。
您正在切片结果。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句