无法解析模块说明符 "stimulus-autocomplete"
Failed to resolve module specifier "stimulus-autocomplete"
Ruby 3.0.3
Rails 7.0.0.alpha2
按照 install and usage 的说明进行操作后,我启动了服务器并收到此错误:Uncaught TypeError: Failed to resolve module specifier "stimulus-autocomplete". Relative references must start with either "/", "./", or "../".
# app/javascript/controllers/application.js
import { Application } from "@hotwired/stimulus"
import { Autocomplete } from "stimulus-autocomplete"
# and tried import { Autocomplete } from 'stimulus-autocomplete/src/autocomplete'
const application = Application.start()
application.register('autocomplete', Autocomplete)
// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
export { application }
如果您使用导入映射,您是否在 config/importmap.rb 中添加了 "stimulus-autocomplete"
以便可以导入库?
pin "stimulus-autocomplete", to: "https://cdn.jsdelivr.net/npm/stimulus-autocomplete@3.0.2/src/autocomplete.min.js"
Ruby 3.0.3
Rails 7.0.0.alpha2
按照 install and usage 的说明进行操作后,我启动了服务器并收到此错误:Uncaught TypeError: Failed to resolve module specifier "stimulus-autocomplete". Relative references must start with either "/", "./", or "../".
# app/javascript/controllers/application.js
import { Application } from "@hotwired/stimulus"
import { Autocomplete } from "stimulus-autocomplete"
# and tried import { Autocomplete } from 'stimulus-autocomplete/src/autocomplete'
const application = Application.start()
application.register('autocomplete', Autocomplete)
// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
export { application }
如果您使用导入映射,您是否在 config/importmap.rb 中添加了 "stimulus-autocomplete"
以便可以导入库?
pin "stimulus-autocomplete", to: "https://cdn.jsdelivr.net/npm/stimulus-autocomplete@3.0.2/src/autocomplete.min.js"