[英]Display multiple dates on React Calendar
I want to display multiple dates using react calendar ( https://www.npmjs.com/package/react-calendar ). 我想使用react日历( https://www.npmjs.com/package/react-calendar )显示多个日期。 The issue lies in that the calendar selects all dates in between instead of each date individually.
问题在于日历选择了之间的所有日期,而不是单独选择每个日期。
For example, I have two dates Jun 4, 2019, and Jun 9, 2019. The calendar should only select the 4th and the 9th but it's also selecting the 5th, 6th, 7th, and 8th. 例如,我有两个日期2019年6月4日和2019年6月9日。日历只应选择4号和9号,但也应选择5号,6号,7号和8号。 I want to select only Jun 4 and Jun 9. I attached an example of what I want to implement using react-dates DayPickerSingleDateController.
我只想选择6月4日和6月9日。我附上了一个我想使用react-dates DayPickerSingleDateController实现的示例。 Is it possible to implement the same thing but using react-calendar?
是否可以使用react-calendar实现相同的事情?
<Calendar
value={[new Date(2019, 5, 4), new Date(2019, 5, 9)]}
/>
I expect the calendar to only show these 2 dates and not the days in between. 我希望日历只显示这两个日期,而不显示两者之间的日期。
This will help: 这将有助于:
import React, { Component } from 'react';
import Calendar from 'react-calendar';
class MyApp extends Component {
state = {
date: new Date(),
}
onChange = date => this.setState({ date })
render() {
return (
<div>
<Calendar
onChange={this.onChange}
value={this.state.date}
selectRange={true}
/>
</div>
);
}
}
selectRange
will help you to achieve your goal. selectRange
将帮助您实现目标。 Here is the source. 这是来源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.