我最近进入了nextjs,我想使用Full-calendar进行反应,但是它不起作用,它一直说我的fullCalendar没有定义。我认为原因是因为它是从服务器渲染的,并且无法识别jquery,有什么办法可以做到这一点?
Cannot set property 'fullCalendar' of undefined
TypeError: Cannot set property 'fullCalendar' of undefined
at Object.<anonymous> (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:26051:19)
at $.fullCalendar.version (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:26028:37)
at Object.map../af (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:26037:3)
at __webpack_require__ (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:30:30)
at Object.defineProperty.value (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:25910:21)
at __webpack_require__ (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:30:30)
at Object.<anonymous> (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:41903:18)
at __webpack_require__ (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:30:30)
at C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:76:18
at C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:79:10
at webpackUniversalModuleDefinition (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:3:20)
at Object.<anonymous> (C:\Users\jarka\OneDrive\Desktop\hr-website\hr-next-graphql\next\node_modules\fullcalendar-reactwrapper\lib\index.js:10:3)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
答案 0 :(得分:-1)
您可能想升级到FullCalendar V4,因为它不依赖jQuery,因此可以轻松地与React集成。它还具有最近发布的official FullCalendar React component。
然后对于FullCalendar React组件文档,您可以参考here。
为了将FullCalendar与Next.js集成,我在how to use FullCalendar in Next.js上写了一篇文章。您可能想阅读一下。
我希望这会有所帮助。