reactjs - 如何使用 react-big-calendar onRangeChange 选项
问题描述
我不想移动日历月,所以使用此代码
const FullCalendar = (props) => {
const { calendarInfos, height, dateInfo } = props
const { selectDate } = dateInfo
const localizer = momentLocalizer(moment);
return (
<>
<CalendarCss />
<Calendar
toolbar={false}
popup={false}
localizer={localizer}
culture='ko'
views={['month']}
events={calendarInfos}
defaultDate={new Date(moment(selectDate))}
startAccessor="start"
endAccessor="end"
onRangeChange={(e)=>{console.log(e)}}
style={{
height: height + 'px',
width: '100%',
}}
components={
{
event: (e) =>
(
<FullCalendarEvent
event={e}
/>
)
,
}
}
/>
</>
);
};
但是这段代码有一个错误。
如何使用反应大日历选项 onRangeChange
解决方案
根据文档,它取决于视图(排序)。
const onRangChange = (Range: [Date]) => do something
// or, the more likely
const onRangChange = ({start: Date, end: Date}) => do something
应该对所有内置视图使用第二种类型,所以不确定第一种类型何时合格......
如果您试图限制它每月移动,更好的选择是使用受控date
道具并进行一些检查以确定您是否设置它。
推荐阅读
- angular - 当前模块路径的子节点返回“未定义”
- c# - 用户角色被创建,但刷新网页时网站崩溃
- c# - 即使在发送消息后,ShowTypingMiddleware 仍然显示指示器
- javascript - 单击 react-big-calendar 中的事件后显示弹出框
- excel - 使用 Application.Run 在另一个用户表单中调用用户表单的子例程
- excel - 用于查找和提取范围内匹配值的 VBA 代码
- java - 简化java枚举测试
- postgres-xl - 错误:分布式表的唯一索引必须包含散列分布列。什么时候从 postgresql 迁移到 postgresql-xl
- sql - 如何让 apache ignite 使用所有 CPU 进行 SQL 查询?
- linux - gitlab-runner 在 CI 中损坏,手动工作 - Debian 发布升级有问题?