Created
July 6, 2018 09:21
-
-
Save 1c7/2b61ed28a639fcb48c8a4db5b48c3ff7 to your computer and use it in GitHub Desktop.
truncate string filter for Vue.js
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('fm-truncate', function (value, length) { | |
if (!value) return '' | |
value = value.toString() | |
if(value.length > length){ | |
return value.substring(0, length) + "..." | |
}else{ | |
return value | |
} | |
}) | |
## Example | |
``` | |
{{topic.title | fm-truncate(5) }} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fm-
preview just meanfacial mask
you can change the
fm-truncate
to whatever you like