slouma2000
9/26/2016 - 5:29 AM

Vuejs Filter Limit

Vuejs Filter Limit

Vue.filter('limit', function(array, length) {
    var limitCount = parseInt(length, 10);
    if (limitCount <= 0) {
        ("development") !== 'production' && _.warn(
            'The limit filter requires an argument defining the limit count.'
        );
        return array;
    }
    return array.slice(0, limitCount);
});


//--------

<tr v-for="item in data | limit 3">
    <td>@{{ item.fakename }}</td>
</tr>