【问题标题】:Vue good table firstSortType and initialSortBy not workingVue良好的表首先SortType和初始SortBy不起作用
【发布时间】:2020-07-16 08:45:00
【问题描述】:

我正在为我的表使用 vue-good-table。我尝试使用firstSortTypeinitialSortBy 对数据进行降序排序,它根本没有对表格进行排序。它总是按升序对表格进行排序。我的桌子看起来像这样

我试过这样firstSortType

  {
          label: "Tracking Number",
          field: "docket_no",

          sortable: true,
          firstSortType: "desc"
        },

初始排序方式

<vue-good-table

              :columns="tableColumns1"
              :rows="shipments"
              :line-numbers="true"

              :search-options="{
    enabled: true,
       placeholder: 'Type to search',
  }"

    :pagination-options="{
    enabled: true,
     mode: 'pages',
     
  }"

   :sort-options="{
enabled: true,
initialSortBy: [

  {field: 'docket_no', type: 'desc'}
],

}" />

当我尝试使用 initialSortBy 时,它会显示此错误

TypeError: Cannot read property 'setInitialSort' of undefined

【问题讨论】:

    标签: vue.js vue-good-table


    【解决方案1】:

    经过大量研究,我能够通过添加 v-if 来解决这个问题,

    <vue-good-table 
      v-if="rows && rows.length"
      :rows="rows"
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-02
      • 2011-12-23
      相关资源
      最近更新 更多