[Vuejs]-Filtering array and display only filtered items

3๐Ÿ‘

โœ…

You can for example use two computed:

computed: {
  hardSkills() {
    return this.skills.filter(skill => skill.type === 'hard');
  },
  softSkills() {
    return this.skills.filter(skill => skill.type === 'soft');
  }
}

1๐Ÿ‘

You could create the 2 arrays with a simple filter like this

const hardSkills = skills.filter(skill => skill.type === 'hard')
const softSkills = skills.filter(skill => skill.type === 'soft')

Then, go to your template and loop on those in your template.

Leave a comment