[英]airbnb/react-dates Display Week Number on DayPickerRangeController
Using DayPickerRangeController
from airbnb/react-dates (12.7.1), I would like to display the week number on the left of the day picker for each weeks.使用
DayPickerRangeController
/react-dates (12.7.1) 中的 DayPickerRangeController,我想在每周的日期选择器左侧显示周数。
Here is what I currently have这是我目前拥有的
Here is what I would like to see on my calendar这是我希望在我的日历上看到的内容
Is there any prop that can help or is there an already existing solution?是否有任何道具可以提供帮助,或者是否已经存在解决方案?
airbnb/react-dates
does not support any props to display the week no. airbnb/react-dates
不支持任何显示周数的道具。 You can have a look at rc-calender as other alternative.你可以看看rc-calender作为其他选择。
As mentionned by @ShridharBavannawa, there's currently no support for displaying week number.正如@ShridharBavannawa 所提到的,目前不支持显示周数。 However, there's a related issue open on github where Jussi Niinikoski suggests a hack that help;
然而,github 上有一个相关的问题, Jussi Niinikoski提出了一个有用的 hack; Instead of displaying week number on the side of each week, one can display them in every date cell with the
renderDayContents
property as follow:可以使用
renderDayContents
属性在每个日期单元格中显示它们,而不是在每周的一侧显示周数,如下所示:
renderDayContents={(day) => (
<>
<p>{day.format('W')}</p>
<p>{day.format('D')}</p>
</>
)
Where day would be a momentJS object. day 是momentJS对象的地方。 You can then style the cell to your taste.
然后,您可以根据自己的喜好设置单元格的样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.