Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

Rails- Bootstrap dropdown is not working in Rails project

I develop a web project and I want to use bootstrap dropdown but dropdown is not working. I create a new project and tried to use dropdown and it worked. It seems to my settings are wrong but I don't know which one is wrong.

application.js

import "bootstrap"
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require ("font_awesome5")
require ("toastr")
require ("jquery")
require("popper")
require("trix")
require("@rails/actiontext")

package.json

{
  "name": "coolby",
  "private": true,
  "dependencies": {
    "@rails/actioncable": "^6.0.0",
    "@rails/actiontext": "^6.0.3-4",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "4.3.0",
    "channels": "^0.0.4",
    "popper": "^1.0.1",
    "popper.js": "^1.16.1",
    "toastr": "^2.1.4",
    "trix": "^1.2.0",
    "turbolinks": "^5.2.0"
  },
  "version": "0.1.0",
  "devDependencies": {
    "bootstrap": "4.5.3",
    "jquery": "^3.5.1",
    "webpack": "^5.12.2",
    "webpack-dev-server": "^3.11.1"
  }
}

enviroment.js

const {environment} = require('@rails/webpacker')

const webpack = require("webpack")

environment.plugins.append("Provide", new webpack.ProvidePlugin({

    $: 'jquery',

    jQuery: 'jquery',

    Popper: ['popper.js', 'default']

}))

module.exports = environment

application.scss

 *= require bootstrap
 *= require_tree .
 *= require_self
 *= require trix
 */
@import 'font_awesome5_webfont';
@import "toastr";
@import "./actiontext.scss";
question from:https://stackoverflow.com/questions/65647593/rails-bootstrap-dropdown-is-not-working-in-rails-project

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...