Bootstrap 4.1.1 Navbar not working with Angular 6

前端 未结 4 503
鱼传尺愫
鱼传尺愫 2021-01-13 03:05

I have been trying to work on Navbar with collapse menu and dropdown link using Bootstrap 4.1.1 and Angular 6 but somehow Navbar is not working at all. I can see elements co

相关标签:
4条回答
  • 2021-01-13 03:29

    just add umd directries popper in script.

     "./node_modules/popper.js/dist/umd/popper.min.js",
    
    0 讨论(0)
  • 2021-01-13 03:38

    path to popper should be : node_modules/popper.js/dist/umd/

            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
    
    0 讨论(0)
  • 2021-01-13 03:39

    After some time i have only put the bootstrap library below the jquery and the popper order...

    "styles": [
                  "src/styles.scss",
                  "node_modules/bootstrap/dist/css/bootstrap.min.css"
                ],
                "scripts": [
                  "node_modules/jquery/dist/jquery.min.js",
                  "node_modules/popper.js/dist/umd/popper.min.js",
                  "node_modules/bootstrap/dist/js/bootstrap.min.js",
                  "node_modules/fontawesome/index.js"
                ]
    
    0 讨论(0)
  • 2021-01-13 03:49

    I have lost 2 hours chasing ghosts. Notice that there is two scripts segment in angular.json. One under test and one under build. You should add under build segment. I was adding under test so angular didn't see bootstrap, and popper js

    "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist/myBootstrapTestApp",
                "index": "src/index.html",
                "main": "src/main.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.app.json",
                "assets": [
                  "src/favicon.ico",
                  "src/assets"
                ],
                "styles": [
                  "src/styles.scss"
                ],
                "scripts": [
                  "node_modules/jquery/dist/jquery.js",
                  "node_modules/popper.js/dist/umd/popper.min.js",
                  "node_modules/bootstrap/dist/js/bootstrap.js"]
              },
    
    0 讨论(0)
提交回复
热议问题