antd设置多少字符后省略
smile唐
共 401字,需浏览 1分钟
·
2023-06-19 01:21
组件:
prefixCount 前缀字符个数
const EllipsisMiddle = ({ prefixCount, children }) => {
const start = children.slice(0, prefixCount).trim();
const suffix = children.length > prefixCount ? "..." : ""
return (
<Title
style={{
maxWidth: '500px',
fontSize: "14px",
fontWeight: "normal",
marginBottom: "0px",
}}
ellipsis={{
suffix: suffix,
}}
level={5}
>
{start}
</Title>
);
};
组件调用:
<EllipsisMiddle
prefixCount={15}
>
{item.goods_title}
</EllipsisMiddle>
文档链接:https://4x.ant.design/components/typography-cn/
博客地址:https://www.tangxuansite.com
评论