【问题标题】:How to sort vuesax table component data in descending order by default?vuesax表格组件数据如何默认降序排序?
【发布时间】:2021-09-14 14:05:10
【问题描述】:

我正在尝试默认按降序对我的 vuesax 表组件数据进行排序并显示。但默认情况下它是升序的,当点击表格中的标题 Id 时,它会在 vuesax 中的 sort-key 属性的帮助下以降序排序。任何人都可以帮我将其默认更改为降序。我的脚本在 Vue.Js 中

我的Vuesax表格组件代码

 <template slot="thead">
    <vs-th sort-key="id">Id</vs-th>
    <vs-th sort-key="first_name">Name</vs-th>
 </template>

<template slot-scope="{data}">
  <tbody>
    <vs-tr :data="tr" :key="indextr" v-for="(tr, indextr) in data">
       <vs-td>
        <p class="product-name font-medium truncate">{{ tr.id }}</p>
       </vs-td>  
     </vs-tr>
  </tbody>
</template>

【问题讨论】:

    标签: sorting vue.js


    【解决方案1】:

    我想你会在这里找到答案:https://eslint.vuejs.org/rules/sort-keys.html

    在您的 main.js 文件中,您应该已经导入了 Vuesax。如果没有,您可以执行以下操作并添加相关选项(来自上面的链接):

    import Vuesax from 'vuesax'
    import 'vuesax/dist/vuesax.css'
    
    Vue.use(Vuesax, {
      // options here
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-20
      • 1970-01-01
      • 2016-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-24
      • 1970-01-01
      相关资源
      最近更新 更多