3 回答

TA贡献1806条经验 获得超5个赞
假设您使用的是 vuetify 2.2.x,则可以使用 v 数据表的分页事件。
<v-data-table
@pagination="yourMethod"
...
调用您的方法
methods: {
yourMethod(pagination) {
console.log(pagination.itemsLength) // length of filtered/searched items in Vuetify data-table
},
分页事件传递给您的方法的分页参数包含以下信息:
{
page: number
itemsPerPage: number
pageStart: number
pageStop: number
pageCount: number
itemsLength: number
}

TA贡献1816条经验 获得超4个赞
我假设您正在使用属性来过滤掉您的数据。如果是这样,您需要添加对表 的引用。然后,您可以获取过滤项目的数组,如下所示:.search
ref="myTable"
this.$refs.myTable.selectableItems
如果是其他一些过滤方法,则方法是相同的 - 使用refs。

TA贡献1829条经验 获得超4个赞
我通过在我的搜索字段和显示的数据上放置一个手表来做到这一点。我还必须添加一个超时,因为否则,它将显示搜索发生之前显示的当前记录量。
@Watch('search')
@Watch('table.data')
onSearchChanged() {
setTimeout(() => {
const table = (this.$refs.dynamoTable as any);
this.filteredItemCount = table?.itemsLength || 0;
}, 1200);
}
我这样做,以便我可以显示搜索提示。
get searchHint(): string {
const count = this.filteredItemCount;
const total = (this.table.data?.length)
? this.table.data.length
: 0;
return this.$t('search_records', { count, total });
}
然后,它作为搜索提示在我的搜索文本字段中正确显示。
<v-text-field class="ml-2"
v-model="search"
prepend-inner-icon="filter_list"
:disabled="!table.data || !table.data.length"
:label="$t('filter')"
clearable
:hint="searchHint"
:persistent-hint="true"
/>
这是在Vuetify的1.5.24版本上。
添加回答
举报