mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
|
import React from 'react';
|
||
|
import { Button, Form, Input, message, Space } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [form] = Form.useForm();
|
||
|
|
||
|
const onFinish = () => {
|
||
|
message.success('Submit success!');
|
||
|
};
|
||
|
|
||
|
const onFinishFailed = () => {
|
||
|
message.error('Submit failed!');
|
||
|
};
|
||
|
|
||
|
const onFill = () => {
|
||
|
form.setFieldsValue({
|
||
|
url: 'https://taobao.com/',
|
||
|
});
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<Form
|
||
|
form={form}
|
||
|
layout="vertical"
|
||
|
onFinish={onFinish}
|
||
|
onFinishFailed={onFinishFailed}
|
||
|
autoComplete="off"
|
||
|
>
|
||
|
<Form.Item
|
||
|
name="url"
|
||
|
label="URL"
|
||
|
rules={[{ required: true }, { type: 'url', warningOnly: true }, { type: 'string', min: 6 }]}
|
||
|
>
|
||
|
<Input placeholder="input placeholder" />
|
||
|
</Form.Item>
|
||
|
<Form.Item>
|
||
|
<Space>
|
||
|
<Button type="primary" htmlType="submit">
|
||
|
Submit
|
||
|
</Button>
|
||
|
<Button htmlType="button" onClick={onFill}>
|
||
|
Fill
|
||
|
</Button>
|
||
|
</Space>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|