[Vuejs]-Add count (.length) each items in option on v-select

0👍

Few Observations in current code you posted :

  • You are checking for online.complete === 100 but you don’t have complete property in online object. Hence, corrected that to completed instead of complete.
  • closing braces is missing from online.title expression.

Now coming to the original problem :

To achieve the counts in the v-select options. You have to convert your items array from array of elements to array of objects.

items: ['All', 'passed', 'not complete']

to

items: [{
        name: 'All',
        count: this.onlineCourse.length
      }, {
        name: 'passed',
        count: this.onlineCourse.filter((course) => course.passed)
      }, {
        name: 'not complete',
        count: this.onlineCourse.filter((course) => course.completed === 0)
      }]

Leave a comment