vue.js - vuetify 表自定义排序“TypeError:无法读取未定义的属性'过滤器'”
问题描述
我在 vuetify 中遇到自定义排序实现的问题。
<v-data-table
:headers="table.headers"
:items="table.items"
:search="search"
disable-pagination
:header-props="{sortByText: 'sortiere nach...'}"
:loading="loading"
hide-default-footer
:custom-sort="customSort"
@click:row="rowClickHandler"
/>
这是我现在的 customSort 功能
customSort(items, sortBy, sortDesc, locale) {
if (!this.table.loading) {
console.log(items)
console.log(sortBy)
console.log(sortDesc)
console.log(locale)
}
}
问题是我变胖了
Error in render: "TypeError: Cannot read property 'filter' of undefined"
,也许这取决于我用 axios 获取的异步数据?
我在我的created()
街区里像这样取东西
async fetchUsers() {
await axios
.get('myApiPath')
.then((res) => {
this.table.items = res.data
this.table.loading = false
})
.catch((err) => {
console.log(err)
})
},
解决方案
您需要从customSort()
. 我相信这与您的异步数据获取无关。
customSort(items, sortBy, sortDesc, locale) {
if (!this.table.loading) {
console.log(items.map(e => e.calories));
console.log(sortBy);
console.log(sortDesc);
console.log(locale);
}
// sort items here
return items;
}
这是一个示例custom-sort()
实现。
推荐阅读
- python - django服务器启动时如何启动单个后台任务?
- python - Python Mongoengine:如何绕过无法通过验证的文档以避免崩溃
- r - 使用 R 中的函数和循环填充空矩阵
- kotlin - Kotlin 中这段代码的“懒惰”是什么意思?
- r - 估计与 R 中删失数据的一个变量的相关性
- linux - 如何告诉`make`在哪里可以找到zlib.h?
- genymotion - Genymotion 显示扭曲的图形
- apache - 尝试在 Apache 2.4.29 和 Ubuntu 18.04 上设置安全 WebSocket
- python - 如何使用 Selenium 获取链接
- c++ - 推断指针非类型模板参数的类型