如何使用铁轨导入地图的刺激组件
我想将此刺激组件包括在我的全新Rails 7应用中: https://www.stimulus-components.com/docs/docs/docs/docs/stimulus-dropdown
当我遵循他们的设置方法时,我会在浏览器控制台中获得以下错误: 平台#:1 Undpref TypeError:未能解析模块指定符“ impoinus-dropdown”。相对引用必须以“/”,“ ./”或“ ../”开头。
我在Stackoverflow上找到了这篇文章: 未能解决模块指定器“ stimulus-autocomplete
”我的importmap.rb的“销钉”。
因此,我从此处获取了下拉链接 https://wwww.jsdelivr.com/ppackage/ppackage/npm n. /imporulus-dropdown
并将其放入我的importmap.rb中:
pin "stimulus-dropdown", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/stimulus-dropdown.min.js"
但是它不起作用,并且在我的浏览器控制台中显示404。
我希望有人可以提供帮助,必须有一种简单的方法来在全新的Rails 7应用程序中使用刺激组件。
I want to include this stimulus component into my brand new rails 7 app:
https://www.stimulus-components.com/docs/stimulus-dropdown
When I follow their setup approach, i get the following error in my browser console:
platforms#:1 Uncaught TypeError: Failed to resolve module specifier "stimulus-dropdown". Relative references must start with either "/", "./", or "../".
I found this article on stackoverflow:
Failed to resolve module specifier "stimulus-autocomplete"
which suggests to add a "pin" to my importmap.rb.
So i took the dropdown link from here https://www.jsdelivr.com/package/npm/stimulus-dropdown
and put it into my importmap.rb by:
pin "stimulus-dropdown", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/stimulus-dropdown.min.js"
But it doesnt work and displays a 404 in my browser console.
I hope someone can help, there must be an easy way to use stimulus-components in a brand new rails 7 app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也很挣扎,但我已经弄清楚了它是
第一次运行 -
第二个创建一个名为“下拉'”的刺激控制器 -
然后在完成所有上述所有操作后,将以下代码复制到下拉列表中
,您可以使用刺激下拉列表你的
视图。有关查看示例,请检查网站上的文档。
i was also struggling but i have figured it out
first run -
second create a stimulus controller called 'dropdown' -
then copy-paste the following code into the dropdown controller
After you do all the above you are ready to use stimulus drop-down in your
views. for the view example check the docs on the site.
我建议在
YARN
上添加它,并在纱线添加signulus-dropdown
中添加它。当我面对您的问题时,这对我有用。I suggest adding it with
yarn
as well withyarn add stimulus-dropdown
. This worked for me when I faced your issue.