Skip to content

Instantly share code, notes, and snippets.

@1c7
Created July 6, 2018 09:21
Show Gist options
  • Save 1c7/2b61ed28a639fcb48c8a4db5b48c3ff7 to your computer and use it in GitHub Desktop.
Save 1c7/2b61ed28a639fcb48c8a4db5b48c3ff7 to your computer and use it in GitHub Desktop.
truncate string filter for Vue.js
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) }}
```
@1c7
Copy link
Author

1c7 commented Jul 6, 2018

fm- preview just mean facial mask
you can change the fm-truncate to whatever you like

@1c7
Copy link
Author

1c7 commented Jul 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment