0

I have an array object, and i want to filter that array. I already know how to filter data by single value using computed property,

computed: {
    filteredValue() {
        return this.graphData.filter(data => data.YEAR === this.selectedYears)
    }
},

But i want to filter data by multiple value/array. Suppose i have an array object that has Year: 1901-2000. and i only want to filter only those year which are selected (like 1901, 1902, 1903). Can anyone help me with that. TIA

Alauddin Ahmed
  • 1,128
  • 2
  • 14
  • 34
  • check this: [filtered with multiple values](https://stackoverflow.com/questions/18719383/how-to-filter-an-array-object-by-checking-multiple-values) – Sphinx Feb 09 '18 at 02:08

1 Answers1

0

I think you need to maintain an array of selectedYears.Then,use use it like this.

computed: {
   filteredValue() {
      return this.graphData.filter(data => this.selectedYears.includes(data.YEAR);
  } 
}
Pulkit chadha
  • 816
  • 11
  • 14