学无先后,达者为师

网站首页 编程语言 正文

antd form操作表单元素以及获取值方法,antd form获取某个值

作者:有问题请评论我改 更新时间: 2022-04-05 编程语言
        <FormItem>
          {getFieldDecorator('ticket', {
            rules: [{ required: true, message: '验证码不能为空' }],
          })(
            <Input
              autoComplete="off"
            />}
             placeholder="验证码"
            />,
          )}
        </FormItem>

重置表单值至initialValue

     const { resetFields } = this.props && this.props.form             
     resetFields(['ticket']

获取表单元素值

    const { getFieldValue } = this.props.form
    let ticket = getFieldValue('ticket')

设置表单元素的值

 const { setFieldsValue } =  this.props.form
 setFieldsValue({ ticket: '222' })

antd栅格行与列的基本使用


import { Input, Button, Row, Col } from 'antd'
      const item ={
        label: '博客地址:',
        url: `https://blog.csdn.net/qq_26889291?spm=1011.2124.3001.5343`,
      }
      function renderItem(){
       return(
               <Row type="flex" gutter={[0, 50]} justify="center" align="middle">
                <Col span={3}   offset={1} >{item.label}</Col>
                <Col span={15}><Input value={item.url} id={inputIdArr[index]} /></Col>
                <Col span={4} offset={1}><Button type="primary">复制</Button></Col>
              </Row>
       )

}

原文链接:https://blog.csdn.net/qq_26889291/article/details/122918542

栏目分类
最近更新