[英]How To Get startDate and endDate from RangePicker from ANTD.DESIGN
i'm working ing a react js project and I'm using antd.design Library to show a RangePicker what i'm trying to solve is how can i get the start date and the end date from this RangePicker when user select a period that's my code : 我正在处理一个React js项目,并且我正在使用antd.design库显示RangePicker我要解决的问题是,当用户选择一个时间段时,如何从该RangePicker获取开始日期和结束日期我的代码:
handleChangeDebut =range => {
const valueOfInput1 = moment(range.startDate).format();
const valueOfInput2 = moment(range.endDate).format();
console.log('start date',valueOfInput1);
console.log("end date",valueOfInput2);
}
<DatePicker.RangePicker
style={{ width: "100%" }}
getPopupContainer={trigger => trigger.parentNode}
onChange={this.handleChangeDebut}
/>
the issue is on my handleChange function , i always get the date of the current day is there any attributes in antd design that give us the startDate and the EndDate Selected ? 问题出在我的handleChange函数上,我总是得到当日的日期。antd设计中是否有任何属性可以使我们选择startDate和EndDate?
Thank you for your precious help . 谢谢您的宝贵帮助。
From the documentation, this is the signature of the onChange function function(dates: moment, moment, dateStrings: string, string)
, It looks like start and end date are passed as an array in the first param: 从文档中
function(dates: moment, moment, dateStrings: string, string)
,这是onChange函数的签名function(dates: moment, moment, dateStrings: string, string)
,看起来开始日期和结束日期在第一个参数中作为数组传递:
handleChangeDebut = (range) => {
const valueOfInput1 = range[0].format();
const valueOfInput2 = range[1].format();
console.log('start date',valueOfInput1);
console.log("end date",valueOfInput2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.