imcvampire / vue-truncate-filter

A filter for Vuejs to truncate string
MIT License
57 stars 6 forks source link

Doesn't work with Chinese #12

Closed 1c7 closed 6 years ago

1c7 commented 6 years ago

Example

111 222 333

Issue

clearly it's implement by split(' ') split by empty space doesn't work with Chinese

So

This is more of a "just letting you know", not asking you to change it.

Still thanks you for build this.

imcvampire commented 6 years ago

Do you have any idea how to handle mandarin characters?

1c7 commented 6 years ago

@imcvampire I just wrote this, it work well

Vue.filter('truncate', function (value, length) {
  if (!value) return ''
  value = value.toString()
  if(value.length > length){
    return value.substring(0, length) + "..."
  }else{
    return value
  }
})
1c7 commented 6 years ago

you can close this issue anytime

1c7 commented 6 years ago

😄

1c7 commented 6 years ago

I think I should just close it