Antd之表单清空操作

handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
        if (!err) {
            console.log('Received values of form: ', values);
        }
    });
    //关键代码
    this.props.form.resetFields();
};

----------
<Form onSubmit={this.handleSubmit} layout='inline'>
    <FormItem label={
        channelIndexTxt ||
        channelLayoutTxt ||
        channelTitleTxt ||
        channelDescriptionTxt ||
        channelEnabledTxt
    }>
        {getFieldDecorator('Channel_Datum', {
            rules: [{required: true, message: '必选项!'}],
        })(
            channelEnabledTxt ?
                <Switch
                    checkedChildren="开"
                    unCheckedChildren="关"
                    defaultChecked
                    onChange={this.handleChange}
                />
                :
                <Input
                    placeholder={'pls input ' + (
                        channelIndexTxt ||
                        channelLayoutTxt ||
                        channelTitleTxt ||
                        channelDescriptionTxt

                    )}

                />
        )}
    </FormItem>
    <Button type="primary" htmlType={'submit'}>修改</Button>
</Form>

猜你喜欢

转载自blog.csdn.net/qq_33733970/article/details/80049371
今日推荐