react & antd 相关记录

form表单自定义错误

1
2
3
4
5
6
7
8
9
<Form.Item
rules=[{
required: true,
message: "error"
}, {
validator: this.validator.bind(this)
}]>
<Input />
</Form.Item>
1
2
3
4
5
6
7
8
validator(rule, value, callback) {
if (this.state.error_msg != null) {
callback(error_msg)
return
}

callback() // important
}