如何实现显示超过10个字符就显示省略号?

// 要展示的文本(nickName)

this.nickName = '风一样的女子凤一样的我,有想认识嘛~~'

if (this.nickName.length > 10) {
 
this.nickName = this.nickName.substring(0, 10) + "...";
 
console.log('00', this.nickName)
}
 
备注:
substring() 方法用于提取字符串中介于两个指定下标之间的字符。
posted @ 2018-07-07 10:10  linzhanfeng  阅读(3151)  评论(0编辑  收藏  举报