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

// 要展示的文本(nickName)

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

if (this.nickName.length > 10) {
 
this.nickName = this.nickName.substring(0, 10) + "...";
 
console.log('00', this.nickName)
}
 
备注:
substring() 方法用于提取字符串中介于两个指定下标之间的字符。

猜你喜欢

转载自www.cnblogs.com/linzhanfeng/p/9276484.html