簡體   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