首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法跳过vuetify的数据表中的值?

有没有办法跳过vuetify的数据表中的值?
EN

Stack Overflow用户
提问于 2021-08-25 18:25:56
回答 1查看 29关注 0票数 0

这是我的vuetify数据表

代码语言:javascript
复制
 <v-data-table
            :headers="headersRemittances"
            :items="remittances"
            :loading="loadingRemittances"
            class="elevation-2 col-12 pa-0"
            item-key="index"
            sortBy="identifier"
            update: sort-desc
            hide-default-footer
            disable-pagination
          >

我一直在尝试“跳过”该数组的某些特定元素(因为它们有重复的ID,但擦除它们不是一个选项),可能是使用条件,但我不知道这是否可能。

编辑:

找到了一种使用some()属性并将数据过滤到新数组中的方法,如下所示:

代码语言:javascript
复制
      filterRemittances () {
  this.filteredRemittances = [];
  for (var i = 0; i < this.remittances.length; i++) {
    if (this.filteredRemittances.length == 0) {
    this.filteredRemittances.push(this.remittances[i])
    }
    if (this.filteredRemittances.some(val => val.id != this.remittances[i].id)) {
    this.filteredRemittances.push(this.remittances[i])
    }
  }
}

之后,我在v- filteredRemittance -table中替换了新的数据数组

代码语言:javascript
复制
          <v-data-table
        :headers="headersRemittances"
        :items="filteredRemittances"
        :loading="loadingRemittances"
        class="elevation-2 col-12 pa-0"
        item-key="index"
        sortBy="identifier"
        update: sort-desc
        hide-default-footer
        disable-pagination
      >
EN

回答 1

Stack Overflow用户

发布于 2021-08-25 19:01:01

您需要使用计算器来过滤掉不需要的项,然后将新的过滤表插入到" items“属性中

代码语言:javascript
复制
<template>
          <v-data-table
            :headers="headersRemittances"
            :items="formattedRemittances"
            :loading="loadingRemittances"
            class="elevation-2 col-12 pa-0"
            item-key="index"
            sortBy="identifier"
            update: sort-desc
            hide-default-footer
            disable-pagination
          />
</template>
<script>
export default {
  ....
  computed: {
    formattedRemittances() {
      return this.remmitances.filter(remmitance => remmitance.amount < 200);
    }  
  }
}
</script>

每当this.remmitances发生更改时,formattedRemittances的值都会自动更新

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68928103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档