【发布时间】:2019-04-03 17:09:34
【问题描述】:
我正在使用 react-datepicker 来实现日期和日历,它工作正常我已经成功集成了组件,但是在禁用默认日期方面面临一个问题。我正在使用下面的代码。
<DatePicker customInput={<ExampleCustomInput />} 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
/>
默认说我想禁用 4/25/2019 ,我不能这样做,我看到组件有一个名为 dayClassName 的属性,有没有人用过,我不确定如何传递日期并将css应用于该特定日期。
这是我在其中一个示例中发现的 -
dayClassName={date => getDate(date) < Math.random() * 31 ? 'random' : undefined}
它对我不起作用,不确定如何禁用此特定日期(2019 年 4 月 25 日),对此有何帮助。?
【问题讨论】:
标签: javascript reactjs react-redux react-datepicker