Angular 4 Bootstrap dropdown require Popper.js

前端 未结 4 2032
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 09:28

I have a fresh created Angular 4 CLI app. After running this:

npm install bootstrap@4.0.0-beta jquery popper.js --save

and editing .angular

相关标签:
4条回答
  • 2020-12-23 09:48

    Was same issue, when I updated app to 8 version of Angular. As solution can use bootstrap bundle minified js file instead bootstrap.min.js. Bootstrap bundle included popper.js already. Need to fix angular.json (scripts array in build section), in final will be something like this:

    "scripts": [
        "./node_modules/jquery/dist/jquery.min.js",
        "./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
    ],
    

    For this solution popper.js is not needed in project. Can remove this module:

    npm uninstall popper.js
    

    just in case, jquery needed :)

    Hope, help you

    0 讨论(0)
  • 2020-12-23 09:52

    For Angular 8

    npm install bootstrap jquery popper.js --save

         "styles": [
          "src/styles.scss",
          "node_modules/bootstrap/dist/css/bootstrap.min.css"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.slim.min.js",
          "node_modules/popper.js/dist/umd/popper.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.min.js"
        ],
    
    0 讨论(0)
  • 2020-12-23 09:53

    Include popper.js before bootstrap.js:

    "scripts": [
      "node_modules/jquery/dist/jquery.slim.min.js",
      "node_modules/popper.js/dist/umd/popper.min.js",
      "node_modules/bootstrap/dist/js/bootstrap.min.js"
    ],
    
    0 讨论(0)
  • 2020-12-23 09:56

    For Angular 7

    npm install bootstrap jquery popper.js --save

           "styles": [
              "src/styles.scss",
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.slim.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js"
            ],
    
    0 讨论(0)
提交回复
热议问题