Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

antd的datepicker不能绑定到Form上

对于一个含有时间控件的表单,每次都还需要单独设立一个状态和一个onChange事件来记录它的值。然后再表单提交事件onFinish里再把这个值添加进去。只有一个时间控件还好,但要是时间控件多了,就特别麻烦。。
有没有其他方法?或者已经封装好的组件?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. 使用onFinish

code

  1. 使用validateFields属性
 const [form] = Form.useForm()

  

 const handleOk =  () => {

 const fieldsValue =  form.validateFields()

 console.log('fieldsValue?:>>?',?fieldsValue)

 }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...