Rails 6无法集成光滑轮播

时间:2020-04-29 16:38:33

标签: ruby-on-rails webpack slick.js

我创建了一个全新的项目(rails 6.0.2.2)。现在面临一个问题 testing.js:2 Uncaught TypeError: $(...).slick is not a function整合完成后

我整合光滑轮播的方式是:

  • 添加纱线jquery(取决于它)
  • 纱线添加圆盘传送带
  • app/javascript/packs/application.js
    • require(“ jquery”)
    • require(“光滑轮播”)
    • require(“包装/测试”)
  • config/webpack/environment.js
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
 $: 'jquery/src/jquery',
 jQuery: 'jquery/src/jquery'
})
)

源同时具有jquery和slick-carousel,但是$('.testing').slick()给了我上面的错误

package.json

"dependencies": {
    "@rails/actioncable": "^6.0.0",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "4.2.2",
    "bootstrap": "^4.4.1",
    "jquery": "^3.5.0",
    "slick-carousel": "^1.8.1",
    "turbolinks": "^5.2.0"
  },

0 个答案:

没有答案