【问题标题】:Is there a way to disable resizing and dragging of events for on specific views on React Big Calendar with drag and drop add on?有没有办法通过拖放添加禁用 React Big Calendar 上特定视图的事件大小调整和拖动?
【发布时间】:2020-06-12 16:58:17
【问题描述】:

我在 API 文档中看不到任何允许在特定视图上禁用调整大小/拖放事件的内容。

例如,如果我想仅在月视图中禁用拖放和调整事件大小的功能,但在日视图中保留该功能。

谢谢!

【问题讨论】:

    标签: react-big-calendar


    【解决方案1】:

    我可以通过以下方式做到这一点:

    • 使用onView 事件跟踪日历的视图状态并设置视图更改时的状态。
    • resizeableAccessordraggableAccessor 分配一个函数,如果当前视图设置为“月”则解析为false
        const [currentView, setCurrentView] = useState(DEFAULT_VIEW);
    
        <DnDCalendar
              resizableAccessor={() => currentView !== 'month'}
              draggableAccessor={() = > currentView !== 'month'}
              onView={view => setCurrentView(view)}
              ...
         />
    

    【讨论】:

    • 谢谢你,这就像一个魅力!我认为您可以将此作为公认的答案。
    猜你喜欢
    • 1970-01-01
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多