This commit is contained in:
linfeng 2025-03-26 10:39:24 +08:00
parent 5289ae69d5
commit 14b977b28a
1 changed files with 18 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { Card, Button, Input, Space } from 'antd';
import { Input, Button, Space } from 'antd';
import React, { useState } from 'react';
type InfoCardProps = {
@ -6,24 +6,32 @@ type InfoCardProps = {
}
const InfoCard: React.FC<InfoCardProps> = ({ onAdd }) => {
const [content, setContent] = useState('');
const [addedContents, setAddedContents] = useState<string[]>([]);
const handleAdd = () => {
if (content) {
onAdd(content);
setAddedContents([...addedContents, content]);
setContent('');
}
}
return (
<Card >
// 增大内边距,避免内容被覆盖
<div style={{ border: '1px solid #d9d9d9', padding: '24px' }}>
<Space>
<Input
placeholder='请输入内容'
value={content}
onChange={(e) => setContent(e.target.value)}
>
</Input>
/>
<Button type='primary' onClick={handleAdd}></Button>
</Space>
</Card>
<div style={{ marginTop: '24px' }}>
{addedContents.map((item, index) => (
<div key={index}>{item}</div>
))}
</div>
</div>
);
}
export default InfoCard;