antd 中 Paragraph无收起按钮
// rows 控制超出几行显示省略
// key 保持每一个div的key值 已备diff算法更新
onst [fold, setFold] = useState(false);
const [key, setKey] = useState(0);
// 控制点击展开
const onExpand = () => {
setFold(true)
}
//控制收起
const onCollapse = (e) => {
e.preventDefault();
setFold(false)
setKey(key + 1)
}
<div key={key}>
<Paragraph ellipsis={{ rows, expandable: isShow ? true : false, onExpand: onExpand }}>
{ fold ? <span>{cpntent}<a onClick={onCollapse}>收起</a></span> : cpntent}
</Paragraph>
</div>
本文介绍如何在 Ant Design 的 Paragraph 组件中实现自定义的展开与收起功能,通过状态管理和事件处理实现内容的动态显示与隐藏。
342

被折叠的 条评论
为什么被折叠?



