我们使用 react-datepicker 来实现我们的日历。显示的默认月份由monthsShown控制组件属性控制。当我们说 2- 它显示当前月份 + 下个月。
我正在使用如下的 reat DatePicker
<DatePicker
customInput={<CustomInput disableDateSelection={this.props.dateProps.disableDateSelection} />}
className="w-dtsr-date-picker"
selected={this.state.startDate} //called when the date is clicked
onChange={this.handleChange} //called only when the value is chnaged
monthsShown={2} //number of months to be shown
minDate={this.props.dateProps.minDate} //min days to be shown in the calendar
maxDate={this.props.dateProps.maxDate} //max days to be shown in the calendar
onChangeRaw={this.handleDateChangeRaw} //preventing the user from manually entering the dates or text in the input text box
dayClassName={date => date.getTime() === new Date(this.props.dateProps.defaultDate).getTime() && this.props.dateProps.disableDefaultDate ? 'random' : undefined}
//dayClassName - to disable the proposed forecast dates or actual dates if user has already selected/proposed the same forecast/actual dates
disabled={this.props.dateProps.disableDateSelection}
/>
有没有办法显示上个月和本月。?例如,如果当前月份是四月,我们希望显示三月和四月而不是四月 - 五月。