日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

antd獲取表單的所有數(shù)據(jù)

作者:摸爬滾打的前端 更新時間: 2022-01-03 編程語言

當(dāng)我們使用antd的組件的form表單時,數(shù)據(jù)一般在form中的onFinish={onFinish}方法上可以拿到

const Demo = () => {
  const onFinish = (values: any) => {
    console.log("表單數(shù)據(jù)",values);
  };

我們還可以使用 const [form] = Form.useForm() 拿到表單的數(shù)據(jù)

具體步驟

1.引入ant,拿到Form,定義hooks

import form {Form} from 'antd'

const [form] = Form.useForm()

2.在form表單寫入form

<Form
  name="nest-messages"
  onFinish={onFinish}
  form={form}                  //form
>
    <Button type="primary" htmlType="submit" onclick={btnValue}>
      Submit
    </Button>
</Form>

3.通過?form.getFieldValue 獲取表單數(shù)據(jù)

  const btnValue = ()=>{
    console.log(form.getFieldsValue());
  }

打印出來就是我們表單所填寫的數(shù)據(jù)啦

原文鏈接:https://blog.csdn.net/m0_59213774/article/details/122096746

欄目分類
最近更新