<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