[Vuejs]-Multiple returns in a computed property

0👍

A function will only reach one return so not sure what you’re doing with sortedItems.

You would never be responsible for running nearby yourself. nearby runs whenever items changes. What you can do instead is have a single results computed property and do something like:

computed: {
  results () {
    return this.items
      .filter(...)
      .sort(...)
  },
},

and use results in your template.

Also:

items.status=="New" | items.status=="in-progress"

should be:

items.status=="New" || items.status=="in-progress"

or even better:

items.status === "New" || items.status === "in-progress"`.

Leave a comment