onSelectSlot在Mobile react Big日历中不起作用

时间:2019-02-07 11:23:25

标签: javascript reactjs fullcalendar react-big-calendar

OnSelectSlot在移动浏览器中不起作用。 在Android设备中,我使用chrome浏览器对其进行了调试,但无法正常工作。 在IOS设备中,我使用Safari浏览器进行了调试,但该调试也不起作用。 在计算机浏览器中,单击时可以流畅运行,但在手机上则不能。有人知道解决此问题的方法吗?

下面是代码-------------------

           <BigCalendar
                selectable
                events={[
                    {
                        id: 0,
                        title: <div>{this.state.morningShiftAppointments + this.state.eveningShiftAppointments}<br/>
                            <div>{this.state.morningShiftAppointments}/{this.state.eveningShiftAppointments}</div>
                        </div>,
                        allDay: true,
                        start: new Date(this.state.year, this.state.month, this.state.date),
                        end: new Date(this.state.year, this.state.month, this.state.date),
                    }
                ]}
                views={['month']}
                onSelectSlot={this.onSelectSlot.bind(this)}
                dayPropGetter={customDayPropGetter}
                longPressThreshold={1}
                defaultDate={new Date()}
                eventPropGetter={
                    (event, start, end, isSelected) => {
                        let newStyle = {
                            backgroundColor: "lightgrey",
                            color: 'black',
                            borderRadius: "0px",
                            border: "none",
                            minWidth: "100%"
                        };
                        return {
                            className: "",
                            style: newStyle
                        };
                    }
                }
            />

2 个答案:

答案 0 :(得分:1)

来自React-Big-Calendar文档:

  

longPressThreshold   指定用户必须经过的毫秒数   按住屏幕以将其视为“长时间   按下。”长按用于触摸时的时隙选择   设备。

     

类型:数字   默认值:250

答案 1 :(得分:1)

尝试通过重新安装react-big-calendar将其更新为最新版本。 我执行以下步骤:

  1. 通过以下方式卸载:npm uninstall --save react-big-calendar
  2. 安装:npm install --save react-big-calendar
  3. 然后将其导入:import { Calendar, momentLocalizer } from 'react-big-calendar';
  4. 根据需要添加本地化器const localizer = momentLocalizer(moment);
  5. 然后为您的组件添加localizer<BigCalendar localizer={localizer} .../>

  6. 在最后一步,将longPressThreshold属性添加到您的组件中(这允许onSelectSlot在移动设备上工作): <BigCalendar longPressThreshold={10} .../>