[英]Rails 7 failing to import yarn package (https://github.com/keisto/vanilla-rangeslider)
This is a non-jQuery version of IonRangeSlider ( https://github.com/IonDen/ion.rangeSlider ):这是 IonRangeSlider ( https://github.com/IonDen/ion.rangeSlider ) 的非 jQuery 版本:
https://github.com/keisto/vanilla-rangeslider https://github.com/keisto/vanilla-rangeslider
I have used this before by trying to stick to pure JS and avoid adding another layer with JQ.我之前通过尝试坚持使用纯 JS 并避免使用 JQ 添加另一层来使用它。
I installed this via yarn and it's in my node_modules folder.我通过 yarn 安装它,它在我的 node_modules 文件夹中。
I added this to my app/javascript/application.js
file:我将其添加到我的app/javascript/application.js
文件中:
import IonRangeSlider from 'vanilla-rangeslider/js/rangeslider'
after also trying just:在也尝试过之后:
import IonRangeSlider from 'vanilla-rangeslider'
In my compiled JS file in dev all it has is this:在我在 dev 中编译的 JS 文件中,它只有这样:
// ../../node_modules/vanilla-rangeslider/js/rangeslider.js
var require_rangeslider = __commonJS({
"../../node_modules/vanilla-rangeslider/js/rangeslider.js"() {
}
});
and if I try and initialize a slider all I get is:如果我尝试初始化 slider,我得到的是:
Uncaught ReferenceError: ionRangeSlider is not defined
Any ideas here as to what I am missing?关于我缺少什么的任何想法? I have added some other yarn based JS package with no issues.我添加了一些其他基于 yarn 的 JS package,没有任何问题。
The range slider has no exported functions, meaning you won't be able to import anything from it.范围 slider 没有导出函数,这意味着您无法从中导入任何内容。
The only way to use its functions would be to add it in a script
tag unfortunately.不幸的是,使用其功能的唯一方法是将其添加到script
标签中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.