【问题标题】:How to toggle antd Typography.Paragraph ellipsis如何切换antd Typography.Paragraph ellipsis
【发布时间】:2019-09-29 00:39:00
【问题描述】:

我正在使用<Typography.Paragraph> 组件来显示列表中某些项目的描述。我想将描述中的行数限制为 2。

现在我可以使用<Typography.Paragraph>ellipsis 属性将描述限制为仅显示2 行并将其设置为可扩展。但是,我似乎无法找到一种方法将文本折叠回仅有 2 行的省略号 (...)

这是我当前代码的 sn-p。

const listOfLongText = [.....];

listOfLongText.map((text,i) => {
    <Paragraph ellipsis={{ rows: 2, expandable: true }}> 
        {text}
    </Paragraph>
})

我知道 ellipsisParagraph 属性的 onExpand 回调,但不知道如何使用 onExpand 在展开和折叠功能之间进行切换

&lt;Typography.Paragraph&gt; API 定义为 here


如果您需要更多信息,请发表评论,我会提供。

【问题讨论】:

    标签: reactjs antd


    【解决方案1】:

    在当前的antd 版本(3.23.4)中没有这样的选项。

    你需要通过状态来控制它,例如:

    <Paragraph
      ellipsis={{
        rows: 3,
        expandable: true,
        onExpand: this.typoExpand
      }}
    >
      Ant Design, a design language for background applications, is refined by Ant
      UED Team. Ant Design, a design language for background applications, is
      refined by Ant UED Team. Ant Design, a design language for background
      applications, is refined by Ant UED Team. Ant Design, a design language for
      background applications, is refined by Ant UED Team. Ant Design, a design
      language for background applications, is refined by Ant UED Team. Ant Design,
      a design language for background applications, is refined by Ant UED Team.
    </Paragraph>;
    

    【讨论】:

    • 感谢您的回答。你能提供一些如何制作typoExpand函数的伪代码吗? @丹尼斯
    • 它在答案中只需点击沙盒按钮
    猜你喜欢
    • 1970-01-01
    • 2019-08-10
    • 2022-01-11
    • 2021-05-16
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 2019-03-14
    • 2022-12-13
    相关资源
    最近更新 更多