Chris Benseler Chris Benseler - 1 year ago 361
Javascript Question

Vue.js: can't orderBy in v-for

I've upgraded to Vue.js 2.0.5 and orderBy in a v-for seems to not be working anymore

<li v-for="c in rooms | orderBy 'last_iteraction'">


  • invalid expression: v-for="c in rooms | orderBy 'last_iteraction'"

anyone knows how to solve?

Answer Source

orderBy Filter is removed in vue.js v-2.

Quoted from vue.js docs

Instead of:

<p v-for="user in users | orderBy 'name'">{{ }}</p>

Use lodash’s orderBy (or possibly sortBy) in a computed property:

<p v-for="user in orderedUsers">{{ }}</p>

computed: {
  orderedUsers: function () {
    return _.orderBy(this.users, 'name')


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download