Skip to content

Instantly share code, notes, and snippets.

@slouma2000
Last active September 9, 2019 13:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save slouma2000/9aea7cbddf4ec0ae19037f04a9053da7 to your computer and use it in GitHub Desktop.
Save slouma2000/9aea7cbddf4ec0ae19037f04a9053da7 to your computer and use it in GitHub Desktop.
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment