在反应日期选择器上设置最小和最大日期 [英] Set min and max date on react day picker
本文介绍了在反应日期选择器上设置最小和最大日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置最大或最小日期? 例如,我只想限制过去2个月(最小日期)直到今天(最大日期)的日间收盘者.因此用户无法选择明天的日期.谢谢
How do i set maximum or minimum date? Like for instance, i want to limit my daypicker only for the last 2 month (min date) until today (max date). So the user can't choose tomorrow's date. Thanks
http://react-day-picker.js.org/docs/
推荐答案
您需要使用disabledDays
属性.可以传递一组修饰符,如 http://react-day-picker所述. js.org/docs/modifiers
You need to use the disabledDays
property. It can be passed a set of modifiers as detailed at http://react-day-picker.js.org/docs/modifiers
以下应满足您的需求:
var twoMonthsAgo = new Date();
twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2);
<DayPicker disabledDays={
{
before: twoMonthsAgo,
after: new Date()
}} />
这篇关于在反应日期选择器上设置最小和最大日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文