【发布时间】:2021-05-07 15:32:12
【问题描述】:
我使用 --skip-webpack-install 创建了一个新的 rails 应用程序,但似乎虽然默认引导样式有效,但并非所有 javascript 似乎都有效。
我的 application.js 中有 jquery 和 bootstrap js 代码,但添加轮播或类似的东西不起作用。
奇怪的是,模态可以工作...
我的application.js如下
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery3
//= require popper
//= require bootstrap-sprockets
//= require jquery
//= require_tree .
它被导入到应用程序中使用
<%= javascript_include_tag 'application' %>
我的 assets.rb 如下
Rails.application.config.assets.precompile += %w( application.js application.scss )
任何建议都会有帮助,如果您需要更多信息,我可以得到它:)
【问题讨论】:
-
您正在使用 bootstrap gem 或 npm 进行引导?
-
我正在使用引导 gem
-
我试图避免使用 webpack,.scss 的工作方式真的很奇怪,自定义 js 正在工作,但 bootstrap javascript 似乎没有被正确触发。
标签: javascript ruby-on-rails bootstrap-4