我正在开发一个 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}
/>
Run Code Online (Sandbox Code Playgroud)
问题出在我的handleChange函数上,我总是得到当天的日期,antd设计中是否有任何属性可以为我们提供选择的startDate和EndDate?
感谢您的宝贵帮助。
我试图获取我的Json响应的长度,但是它不起作用,我在json结果中使用了“ length”,这就是我在我的班上在React js中尝试过的:
componentDidMount() {
axios.get(`http://localhost:51492/api/CommentSurExperience/GetAllCommentOfExperience/${this.props.passedVal}`)
.then(res => {
const persons = res.data;
const longeur = res.length;
this.setState({ persons, longeur });
})
}
Run Code Online (Sandbox Code Playgroud)
然后我返回了这个:
<div> <p> { this.state.longeur}</p> </div>
Run Code Online (Sandbox Code Playgroud)
但是我的结果是空的。
我如何计算JSON响应中有多少个元素,请感谢您的帮助。
**********更新***********这是我使用邮递员的JSON结果

这是显示console.log(res)显示的内容的捕获