3

我是 Nuxt 的新手,我正在尝试使用 jquery 库“ionrangeSlider”,但出现错误:

$(...).ionRangeSlider is not a function

我跑了npm i ion-rangeslider,我在我的 nuxt.config.js 中添加了供应商:

build: {
    vendor: [
      "jquery",
      "ion-rangeslider"
    ],
    plugins: [
      new webpack.ProvidePlugin({
        $: "jquery",
      })
    ],
  },

在我的组件中,我有:

mounted(){
   var that = this;
   this.$nextTick(function(){
      $(that.$refs.range).ionRangeSlider();
    },
}

我认为 nuxt 不能正确编译来自 node_modules 的库,但我不知道我能做什么:(

4

0 回答 0