版权声明:本博客内容归个人所有,如需转载,请标明出处。 https://blog.csdn.net/m0_37468171/article/details/89356300
CSS截断显示内容主要通过white-space,overflow,text-overflow三个属性实现。
white-space:nowrap;
强制文本不换行
overflow:hidden;
超过宽度部分进行隐藏
text-overflow: ellipsis;
根据文本长度剩余部分显示为“···”
.class {
width:40rpx;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
字符串提取:
1、slice()
str.slice(beginIndex[,endIndex])
举例: str.slice(1,2)