Search code examples
javascriptcssvue.jscomponents

Vue.js rewriting orderBy Filter in v-for


Since the orderBy Filter is removed in vue.js v-2 I want to now how one can rewrite this codepart:

<li class="day" v-for="day in days | orderBy 'unix' 1" v-bind:class="{ 'outside': day.outsideOfCurrentMonth, 'empty': day.events.length === 0 }">

I thought of writing

<li class="day" v-for="day in orderedDays"{{}}>

but I don't know what to write in the brackets and what to write in orderBy():

computed: {
  orderedDays: function () {
    return _.orderBy()
  }
}

Here is the full component. Can someone help?


Solution

  • <li class="day" v-for="day in orderedDays">
    
    computed: {
      orderedDays: function () {
        return _.orderBy(this.days, ['unix'], ['asc'])
      }
    }