[英]What is the difference 'Form.Item' and 'div' in antd?
i have a question.我有个问题。 the question is about difference 'Form.Item' and 'div'.问题是关于'Form.Item'和'div'的区别。
Could I changes the tag 'Form.Item' to 'div'?我可以将标签“Form.Item”更改为“div”吗?
below, I copy and paste antd docs of 'Form.Item'.下面,我复制并粘贴 'Form.Item' 的 antd 文档。
import React, { useState, useEffect } from 'react';
import { Form, Input, Button } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
const HorizontalLoginForm = () => {
const [form] = Form.useForm();
const [, forceUpdate] = useState();
// To disable submit button at the beginning.
useEffect(() => {
forceUpdate({});
}, []);
const onFinish = values => {
console.log('Finish:', values);
};
return (
<Form form={form} name="horizontal_login" layout="inline" onFinish={onFinish}>
<Form.Item <<<<<<<< here!!! Could i change the tag to 'div'? What is the difference both?
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
>
<Input prefix={<UserOutlined className="site-form-item-icon" />} placeholder="Username" />
</Form.Item> <<<<<<<< here!!! Could i change the tag to 'div'? What is the difference both?
Assume you made a child component named FieldItem and it takes props like rules,name then you imported in parent component and you are going to use it in dis way <FieldItem rule="check" name="test" />
.假设您创建了一个名为 FieldItem 的子组件,它采用了规则之类的道具,然后您将其导入父组件中,并且您将以不同的方式使用它<FieldItem rule="check" name="test" />
。 Do you think you can replace FieldItem with div and provide rules,name props gonna work?你认为你可以用 div 替换 FieldItem 并提供规则,名称道具会起作用吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.