柴坦亚古普塔
在此图像中,我要显示资产名称,最多20个字符,例如aaaaaaaaaaaaaa .....
<td className="truncateText">{assetName}</td>
我正在使用CSS
.truncateText{
text-overflow: ellipsis;
max-width: 0px;
overflow: hidden;
white-space: nowrap;
}
凯坦·拉姆特克(Ketan Ramteke)
您可以使用substr()
method来做到这一点:
<td title={assetName} className="truncateText">
{assetName.length < 20 ? assetName : assetName.substr(0, 20) + "..."}
</td>
示例:世博小吃
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
编辑于
我来说两句