198
rated 0 times
[
200]
[
2]
/ answers: 1 / hits: 25579
/ 7 Years ago, wed, january 24, 2018, 12:00:00
I has worked with Vue for several days, and meet some problem.
I use jQuery AJAX load data (text content) in template, title and description need to be ellipsis, I wrote the methods
↓
methods:{
titleELLIPSIS:function(){
var title = self.articleList.title;//AJAX data
var titleLength = title.length;
var maxWidth = 15;
var newTitle = title.split(,maxWidth);
return title(function(ELLIPSIS){
if(titleLength>maxWidth){
for(var j=newTitle.length-1;j>0;j--){
delete newTitle[j];
var ELLIPSIS = self.innerHTML = newTitle.join('')+'...';
if(newTitle.length<=maxWidth){ break;}
return ELLIPSIS;
}
}
})
}
}
And my template is:
<h2 class=ellipsis-2>{{titleELLIPSIS}}</h2>
How could I return the ellipsis title in h2?
Please give me some idea.
By the way, the AJAX is success, because other data show correctly.
More From » vue.js