首页 > 解决方案 > Vuetify,v-data-table headers 值的用途

问题描述

对象数组中的value属性的目的是什么?headersv-data-table

文档中它说

An array of objects that each describe a header column. See the example below for a definition of all properties.

{
  text: string",
  value: string",
  align: 'left' | 'center' | 'right'",
  sortable: boolean",
  class: string[] | string",
  width: string"
}

但它从未真正解释过它的目的。

标头对象是否只需要一个唯一键或者我可以value在 html 中使用它吗?

标签: vue.jsvuetify.js

解决方案


当您将该列定义为sortable: true时,它将是在分页对象上设置的值,而不是文本。

例如,我的列名为Created at(text),其值为created_at. 这使我可以查看分页对象,并直接按数据发送订单,而无需额外的映射步骤,因为我的 API 期望值为orderBy要么 要么created_at没有。


推荐阅读