0

我正在尝试在 antd 响应卡中添加标题和图标,但无法添加并找到任何解决方案,任何人都可以帮助我解决这个问题,因为我对此很陌生,我无法弄清楚

const data = [
{
title: 'Title 1',
},
{
title:  <SearchOutlined />'Title 2',
},
];

ReactDOM.render(
<List
grid={{
gutter: 16,
xs: 1,
sm: 2,
md: 4,
lg: 4,
xl: 6,
xxl: 3,
}}
dataSource={data}
renderItem={item => (
<List.Item>
<Card title={item.title}>Card content</Card>
</List.Item>
)}
/>,
document.getElementById('container'),
);
4

1 回答 1

0

你很亲密。只需用反应片段附上标题内容

const data = [
  {
    title: "Title 1",
    content: (
      <div>Content 1</div>
    )
  },
  {
    title: (
      <>
        <SearchOutlined /> Title 2
      </>
    ),
    content: (
       <div>Content 2</div>
    )
  }
];

<List
    dataSource={data}
    renderItem={item => (
        <List.Item>
           <Card title={item.title}>{item.content}</Card>
        </List.Item>
     )}
/>
于 2020-10-29T01:53:34.723 回答