【发布时间】:2020-08-19 17:05:56
【问题描述】:
当我打开周视图或日视图时,如果事件不是全天(有一个范围,例如下午 1 点 - 下午 3 点)我有一个错误 - iterate is not a function
_baseOrderBy.js:24 Uncaught TypeError: iteratee is not a function
at _baseOrderBy.js:24
at arrayMap (_arrayMap.js:16)
at _baseOrderBy.js:23
at arrayMap (_baseMap.js:16)
at baseOrderBy (_baseOrderBy.js:22)
at sortBy.js:45
at apply (_apply.js:15)
at _overRest.js:32
at sortByRender (react-big-calendar.esm.js:2430)
at getStyledEvents (react-big-calendar.esm.js:2472)
有人可以帮忙解决这个错误吗?
事件对象示例:
const [events, setEvents] = useState([]);
async function getEvents() {
const events = await api.getEvents();
const eventsList = evetns.map(item => ({
id: item.id,
label: item.label,
start: moment(item.start).toDate(),
end: moment(item.end).toDate(),
}));
setEvents(eventsList);
}
useEffect(() => {
getEvents();
}, []);
return (
<Calendar
events={events}
popup
onSelectSlot={(props) => selectSlot(props)}
/>
)
【问题讨论】:
-
您能否向我们展示您发送日历的事件对象示例?
-
正如 Menawer 提到的,如果您可以编辑您的帖子并包含您运行它的代码,那将非常有帮助。另外,您的错误显示为: iteratee with 2 e's 我假设您的意思是: iterate with 1 e
-
{ allDay: false, end: Fri Aug 21 20:00:00 GMT+0300 (Moscow Standard Time) {}, id: "5f33f23b1e6301000172acc4", start: Thu Aug 20 2020 01:45 :00 GMT+0300(莫斯科标准时间){}, }
-
@BenjaminCharais,这不是一个错误,迭代者。带有 2 个“e”。
-
能否请您也提供我们代码中的函数调用?这对帮助解决问题非常有帮助,编辑您的帖子而不是将其放入 cmets 非常有帮助
标签: reactjs react-big-calendar