【问题标题】:Vuetify data tables search not workingVuetify 数据表搜索不起作用
【发布时间】:2018-12-02 18:30:39
【问题描述】:

我是 Vue 和 Vuetify 的新手。我在我的项目中使用 vuetify 数据表。除了搜索选项外,一切正常。我将所有内容都用作文档。但仍然没有得到任何解决方案。

作为基本要求,我使用这些代码来添加搜索

模板

          <v-text-field
            v-model="search"
            append-icon="search"
            label="Search"
            single-line
            hide-details
          ></v-text-field>

         <v-data-table
          :headers="headers"
          :items="sales"
          :search="search"
          :rows-per-page-items="rowsPerPageItems"

          row
          wrap
          class="elevation-1"
        >

脚本

data(){
      return{
        search: '',
      }
  }  

这是完整的代码 https://github.com/Shakilzaman87/pukucrm/blob/master/src/components/sales/Sales.vue

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    Vuetify 应该在控制台中警告您:

    [Vuetify] 标头必须具有对应于 “v-data-table”中的v-model数组中的值

    因此您可以通过添加值来修复搜索选项:

    headers: [
      { text: 'Item Name', value: 'item_name' },
      { text: 'Unit Price', value: 'price' },
      { text: 'Quantity', value: 'quantity' },
      { text: 'Customer', value: 'customer' },
      { text: 'Created', value: 'timestamp' },
      { text: 'Total', value: 'total' },
      { text: 'Action', value: 'item_name' }
    ]
    

    (来自您的仓库的数据)

    【讨论】:

    • 谢谢。我不知道我是怎么错过的。这是我回到示例时看到的第一件事。
    • 爱你 :) 非常感谢
    猜你喜欢
    • 1970-01-01
    • 2021-11-14
    • 2017-02-22
    • 1970-01-01
    • 2021-03-13
    • 2019-11-13
    • 2017-01-22
    • 2016-10-23
    • 2018-06-25
    相关资源
    最近更新 更多