简体   繁体   English

Rails 7 无法导入纱线 package (https://github.com/keisto/vanilla-rangeslider)

[英]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.

相关问题 Rails:找不到 JavaScript 运行时。 有关可用运行时的列表,请参阅 https://github.com/sstephenson/execjs。 (ExecJS::RuntimeUnavailable) - Rails: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) 来自https://github.com/RubaXa/Sortable的功能要求 - Function required from https://github.com/RubaXa/Sortable 在异步队列内的函数内进行异步Twitter调用-https://github.com/DeviaVir/zenbot - Async twitter call inside a function that is inside a async queue - https://github.com/DeviaVir/zenbot 无法在meanstack MEANIO上运行localhost:3000,https://github.com/linnovate/mean - cannot run localhost:3000 on meanstack MEANIO, https://github.com/linnovate/mean 如何处理“已弃用,请使用https://github.com/pillarjs/path-to-regexp”消息 - how to deal with “DEPRECATED use https://github.com/pillarjs/path-to-regexp” message 如何为Tween.js分配额外的属性(https://github.com/sole/tween.js/) - How to assign extra attributes to Tween.js ( https://github.com/sole/tween.js/ ) 无法使用库https://github.com/hiddentao/linear-algebra运行简单的示例 - Unable to run simple example using library https://github.com/hiddentao/linear-algebra 如何在浏览器中使用“https://github.com/ovvn/dom-to-pdf” - How can I use `https://github.com/ovvn/dom-to-pdf` in a Browser 在本地运行 https://github.com/akella/webgl-mouseover-effects 代码 - Run https://github.com/akella/webgl-mouseover-effects code locally 像Github.com这样的时间表 - Timeline Charts like Github.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM