其他分享
首页 > 其他分享> > react setFieldsValue

react setFieldsValue

作者:互联网

import React from "react";
import { Form, Input } from 'antd';

class TestForm extends React.Component {
  componentDidMount(){
    const { setFieldsValue } = this.props.form;
    // 这里就能实现指定表单设置value
    setTimeout(()=>{
        setFieldsValue({"username": "Tom"})
    },5000)
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form >
        <Form.Item>
          {getFieldDecorator('username', {})(<Input />)}
        </Form.Item>
      </Form>
    );
  }
}

export default Form.create()(TestForm)

 

参考:https://blog.csdn.net/qq_36990322/article/details/97641604

标签:React,const,Form,getFieldDecorator,setFieldsValue,TestForm,react
来源: https://www.cnblogs.com/zhf123/p/16390155.html