标签:form initial field hasd erro ldd 表单 set you
<FormItem {...formItemLayout} label={‘显示名‘}> {getFieldDecorator(‘displayName‘, { initialValue: displayName, validateTrigger: ‘onBlur‘, rules: [ { transform: val => val && val.trim() }, { required: true, message: ‘请输入显示名‘ }, { max: 20, message: ‘显示名长度必须小于等于20字符‘ }, { validator: (rlue, value, cb) => { if (value) { checkNickname(value).then((res) => { const { success, data } = res; // 接口成功 if (success) { // 存在重名 if (data.hasDisplayName) { this.props.setFields({ displayName: { value: displayName, errors: [new Error(‘此显示名已被使用!‘)], }, }) } else { cb(); } } }) } else { cb(); } } } ] })( <Input /> )} </FormItem>
注意cb回调
标签:form initial field hasd erro ldd 表单 set you
原文地址:https://www.cnblogs.com/rong88/p/12156840.html