Rails 7 ImportMaps Fullcalendar 5
我需要以下代码的帮助:
rails 7.0.3
view.html.erb
<div id="calendar"></div>
importmap.rb
pin "fullcalendar", to: "https://ga.jspm.io/npm:[email protected]/main.js"
javascript/application.js
import "fullcalendar"
javascript/controllers/fullcalendar_controller.js
import { Controller } from "@hotwired/stimulus"
import FullCalendar from 'fullcalendar'
export default class extends Controller {
connect() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth'
});
calendar.render();
}
}
layouts/applications.html.erb
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
和输出.. 。:(
未能注册(控制器/fullcalendar_controller)
ReferenceError:未定义出口 在main.js? [SM]:20877:37 *
任何帮助都将不胜感激
I need help with following code:
Rails 7.0.3
view.html.erb
<div id="calendar"></div>
importmap.rb
pin "fullcalendar", to: "https://ga.jspm.io/npm:[email protected]/main.js"
javascript/application.js
import "fullcalendar"
javascript/controllers/fullcalendar_controller.js
import { Controller } from "@hotwired/stimulus"
import FullCalendar from 'fullcalendar'
export default class extends Controller {
connect() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth'
});
calendar.render();
}
}
layouts/applications.html.erb
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
And the output... :(
Failed to register controller: fullcalendar (controllers/fullcalendar_controller)
ReferenceError: exports is not defined
at main.js? [sm]:20877:37*
Any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是在日历JS文件中,您可以将FullCalendar JS文件下载到您的本地项目,
./ bin/importMap Pin fullcalendar -download
,然后您可以在供应商目录下看到fullcalendar.js文件<代码>供应商/javascript/fullcalendar.js 然后用full_calendar源替换该JS文件内容https://cdn.jsdelivr.net/npm/ [email&nbsp; procected] fullcalendar;
。希望它可以帮助您解决问题。The issue is with calendar js file, you can download the fullcalendar js file to your local project,
./bin/importmap pin fullcalendar --download
and then you can see fullcalendar.js file under vendors directoryvendors/javascript/fullcalendar.js
then replace that js file content with the full_calendar sourcehttps://cdn.jsdelivr.net/npm/[email protected]/main.js
finally add export line to end of the fullcalendar.js fileexport default FullCalendar;
. Hope it may help you with your issue.