antd 表单获取参数

wrappedComponentRef是为了把form的值赋值到自定的对象中

<OpenCityForm wrappedComponentRef={(inst)=>{this.cityForm = inst;}}/>
  handleSubmit = ()=>{
        let cityInfo = this.cityForm.props.form.getFieldsValue();
        console.log(cityInfo);
        axios.ajax({
            url:'/city/open',
            data:{
                params:cityInfo
            }
        }).then((res)=>{
            if(res.code == '0'){
                message.success('开通成功');
                this.setState({
                    isShowOpenCity:false
                })
                this.requestList();
            }
        })
    }

表单创建时要加一句话

class FilterForm extends React.Component{

    render(){
        const { getFieldDecorator } = this.props.form;
        return (
            <Form layout="inline">
                <FormItem label="城市">
                    {
                        getFieldDecorator('city_id')(
                            <Select
                                style={{width:100}}
                                placeholder="全部"
                            >
                                <Option value="">全部</Option>
                                <Option value="1">北京市</Option>
                                <Option value="2">天津市</Option>
                                <Option value="3">深圳市</Option>
                            </Select>
                        )
                    }
                </FormItem>
                <FormItem la

表单模块的创建方式

class FilterForm extends React.Component{

    render(){
  }
  }
FilterForm = Form.create({})(FilterForm);

 

posted @ 2019-08-07 16:40  ThisCall  阅读(3365)  评论(0编辑  收藏  举报