我在项目中使用 vuejs2 中的 v-data-table 和多个用户页面,在一组列中显示他们的信息(每页显示 25 个用户,总共 60 000 多个用户)。我想获取我们当前所在页面的用户列表,即使在通过其中一列对值进行排序之后也是如此。 v-data-table 是否提供了一些东西来为您获取此数据,或者您是否必须通过排序和所有内容手动计算它?
我已经知道怎么做了。每当当前列表发生更改时,使用
@current-items
事件进行处理将为您提供当前显示的页面。使用示例:
<v-data-table
:headers="headers"
:items="items"
:items-per-page="25"
:server-items-length="totalUsers"
@current-items="handleCurrentItems">
。 。 .
handleCurrentItems(items) {
// This method will be called whenever the current displayed items change
// You can perform any operations with the current items here
console.log("Current Items:", items);
}