【问题标题】:disable sunday on react-native-calendar-picker react native在 react-native-calendar-picker 上禁用星期日
【发布时间】:2021-05-25 04:42:55
【问题描述】:

我想在 react-native-calendar-picker 中禁用星期日。这里我做了什么,但还没有工作

const disableDate = () => {
    let date = new Date()
    return date.getDay() == 0 ? true : false
}

在日历中

<CalendarPicker
   minDate={minimalDate()}
   initialDate={new Date()}
   disabledDates={disableDate()}
   onDateChange={(res) => setSelectedDate(moment(res).format("D MMMM YYYY"))}
/>

【问题讨论】:

    标签: react-native calendar


    【解决方案1】:

    你应该将日期作为参数传递给你的函数试试这个,

    const disableDate = (date) => {
      return date.getDay() === 0;
    }
    

    【讨论】:

      猜你喜欢
      • 2022-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 2020-03-13
      相关资源
      最近更新 更多