Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Loop throuth a filtered list in vue.js with parameter

How to loop in vue.js through a filtered list with an input parameter given?

Pls. take into consideration that filtering like <li v-for="x in todos_filtered" v-if="x.person == 'Mike'"> should be avoided with many records.

Here the code which returns an empty list instead of 2 elements.

<html>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<body>

<div id="app">
  <ul>
    <li v-for="x in todos_filtered('Mike')">
      {{ x.text }}
    </li>
  </ul>    
</div>

<script>
myObject = new Vue({
  el: '#app',
  data: {  
    todos: [
      { person: 'Mike', text: 'Learn JavaScript' },
      { person: 'Luke', text: 'Learn Vue.js' },
      { person: 'Mike', text: 'Build Something Awesome' }
    ]
  },
  computed: {
    todos_filtered(person) {
      return this.todos.filter((x) => x.person === person);
    }
  },
})
</script>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The computed property should return a function that take the person as parameter:

  computed: {
    todos_filtered() {
      return (person)=> this.todos.filter((x) => x.person === person);
    }
  },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!