[Fixed]-Replacement for filterby in vuejs 2

1👍

You can create a method that will return the filtered list.

Here is an example

var app = new Vue({
    el: '#app',
    data: {
        numbers: [ 1, 2, 3, 4, 5 ]
    },
    methods: {
        even: function (numbers) {
            return numbers.filter(function (number) {
                // your custom logic here
                return number % 2 === 0
            })
        }
    }
});
<script src="https://unpkg.com/vue/dist/vue.js"></script>

<div id="app">
  <ul>
    <li v-for="n in even(numbers)">{{ n }}</li>
  </ul>
</div>

Leave a comment