29 lines
785 B
TypeScript
29 lines
785 B
TypeScript
import { Card, Button, Input, Space } from 'antd';
|
|
import React, { useState } from 'react';
|
|
|
|
type InfoCardProps = {
|
|
onAdd: (content: string) => void;
|
|
}
|
|
const InfoCard:React.FC<InfoCardProps> = ({onAdd}) => {
|
|
const [content, setContent] = useState('');
|
|
const handleAdd = () => {
|
|
if(content){
|
|
onAdd(content);
|
|
setContent('');
|
|
}
|
|
}
|
|
return (
|
|
<Card >
|
|
<Space>
|
|
<Input
|
|
placeholder='请输入内容'
|
|
value={content}
|
|
onChange={(e) => setContent(e.target.value)}
|
|
>
|
|
</Input>
|
|
<Button type='primary' onClick={handleAdd}>添加</Button>
|
|
</Space>
|
|
</Card>
|
|
);
|
|
}
|
|
export default InfoCard; |