<Form {...formItemLayout}><Form.Item label='用户Id'>{getFieldDecorator('uid', {initialValue: undefined,rules: [{ required: true, message: '请输入用户id', pattern: new RegExp(/^[1-9]\d*$/, 'g') }],getValueFromEvent: e => e.target.value.replace(/\D/g, '').replace(/\b(0+)/gi, ''),})(<Input />)}</Form.Item>
</Form>
关键处:
1. getValueFromEvent,输入时替换掉不需要的内容
2. rules中pattern的写法