简体   繁体   English

react-calendar tileDisabled 周六和周日

[英]react-calendar tileDisabled Saturdays and Sundays

I want to disabled every Saturday and Sunday on my react-calendar.我想在我的反应日历上的每个星期六和星期日禁用。 So I used the tileDisabled function like this:所以我像这样使用了 tileDisabled function:

<Calendar
        onChange={setDate}
        value={date}
        minDate={today}
        tileDisabled={({ date, view }) =>
          (view === "month" && date.getDay() === 0) || date.getDay() === 6
        }
      />

This works in some cases, but when I press the month to select another one, some months are disabled, like october in this这在某些情况下有效,但是当我将月份按到另一个 select 时,有些月份被禁用,比如这个月份

在此处输入图像描述

Hope it might works for you.希望它对你有用。

<Calender tileDisabled={({date}) => [0, 6].includes(date.getDay())}

In turn it will disable the day number 6 and 0 which means saturday and sunday.反过来,它将禁用第 6 天和第 0 天,这意味着星期六和星期日。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM