The vue filter cannot give the undefined attribute length (the actual function is normal, but it will not affect the use of error reports)

<h1>{{item.title | cutTitle(70)}}</h1>

title uses a filter

filters: {
    cutTitle: function (str, len) {
      //length1 
      if (str.length * 2 <= len) {
        return str;
      }
      var strlen = 0;
      var s = "";
      for (var i = 0; i < str.length; iPP) {
        s = s + str.charAt(i);
        if (str.charCodeAt(i) > 128) {
          strlen = strlen + 2;
          if (strlen >= len) {
            return s.substring(0, s.length - 1) + "...";
          }
        } else {
          strlen = strlen + 1;
          if (strlen >= len) {
            return s.substring(0, s.length - 2) + "...";
          }
        }
      }
      return s;
    },
  },
The

function is right, and the effect is coming out, but why does it prompt that an undefined attribute length cannot be given

Aug.09,2021

it is estimated that item.title is undefined before api acquires data, and even item is undefined, plus judgment

<h1 v-if="item&&item.title">{{item.title | cutTitle(70)}}</h1>

initialize data. Item should be the list for traversing.

return {
    list:[{title:''}]
}

or wait for the data to come down before rendering

<h1 v-if="item.title">{{item.title | cutTitle(70)}}</h1>
The

request is asynchronous. You need to initialize the data in data, or render < H1 > {{item&&item.title | cutTitle (70)}} < / H1 >, or add a v-if to judge the data and render < H1 VIF = "item.title" > {{item.title | cutTitle (70)} < / H1 >

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b349cd-4d5c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b349cd-4d5c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?