Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

str_limit function filter vuejs

filters:{
    str_limit : function (text,limit) {
      if(!text){
        return '';
      }
     else if(text.length()<limit){
        return text;
      }
      else {
        return text.substring(0,limit);
      }
    }
  }
// register the previous filter in your componenet as a local filter
// then in your html
{{ valueToDisplay | str_limit(256) }} // we set the limit of that text to 256 char
Source by v2.vuejs.org #
 
PREVIOUS NEXT
Tagged: #function #filter #vuejs
ADD COMMENT
Topic
Name
3+9 =