Last active
September 9, 2019 13:25
-
-
Save slouma2000/9aea7cbddf4ec0ae19037f04a9053da7 to your computer and use it in GitHub Desktop.
Vuejs Filter Limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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