You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
281 B

  1. import Vue from 'vue'
  2. export const truncate = function (text, length, clamp) {
  3. text = text || ''
  4. clamp = clamp || '...'
  5. length = length || 30
  6. if (text.length <= length) {
  7. return text
  8. }
  9. return text.substring(0, length) + clamp
  10. }
  11. Vue.filter('truncate', truncate)