The filter in vue realizes that the text content exceeds the display

An ellipsis is displayed after the text content exceeds 10 characters……

  • renderings

    insert image description here

  • filters code

    filters: {
          
          
        ellipsis(value, count) {
          
          
          if (!value) return ''
          if (value.length > count) {
          
          
            return value.slice(0, count) + '...'
          }
          return value
        }
    },
    
  • use

    <li v-for="(item,index) in  classifyList" :key="index">{
          
          {
          
          item.name|ellipsis(10)}}</li>
    

Guess you like

Origin blog.csdn.net/weixin_43363871/article/details/124042740