如何使用项目的其他值搜索Vuetify数据表

时间:2019-08-21 17:27:50

标签: datatable vuejs2 vuetify.js

我的Vuetify数据表项目是这样的JSON对象数组

[
  {
    name: 'Frozen Yogurt',
    calories: 237,
    fat: 9.0,   
    price: 30,
    description: 'something other aaa bbb ...'
  },
  {
    name: 'Ice cream sandwich',
    calories: 621,
    fat: 12.5,
    price: 43,
    iron: '1%',
    description: 'someting other ccc ddd ...'
  }
]

数据表仅设置标题[名称,卡路里,脂肪,价格],因此看不到描述或其他值,我想在支出div中显示的描述,当我输入文本以过滤项目时,如何让搜索描述以过滤项目 你知道怎么做吗?

非常感谢,社区真棒!

1 个答案:

答案 0 :(得分:0)

您可以使用:custom-filter道具。详细信息here

:custom-filter="customFilter"

methods: {
  customFilter(value, search, item) {
    return !!search && (item.name.includes(search) || item.description.includes(search))
  }
}