繁体   English   中英

antd中的'Form.Item'和'div'有什么区别?

[英]What is the difference 'Form.Item' and 'div' in antd?

我有个问题。 问题是关于'Form.Item'和'div'的区别。

我可以将标签“Form.Item”更改为“div”吗?

下面,我复制并粘贴 '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?

在此处输入图像描述

假设您创建了一个名为 FieldItem 的子组件,它采用了规则之类的道具,然后您将其导入父组件中,并且您将以不同的方式使用它<FieldItem rule="check" name="test" /> 你认为你可以用 div 替换 FieldItem 并提供规则,名称道具会起作用吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM