简体   繁体   中英

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 ):

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.

I installed this via yarn and it's in my node_modules folder.

I added this to my app/javascript/application.js file:

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:

  // ../../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:

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.

The range slider has no exported functions, meaning you won't be able to import anything from it.

The only way to use its functions would be to add it in a script tag unfortunately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM