Navbar在引导程序中不起作用:4.0.0-beta.2

时间:2017-11-24 20:26:11

标签: javascript css twitter-bootstrap angular bootstrap-4

我已安装最新版本的Bootstrap

"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"popper.js": "^1.12.9",

我实施了navbar

<nav class="navbar navbar-expand-md navbar-light bg-light" *ngIf="!isLogged">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active" routerLinkActive="active current">
        <a class="nav-link" routerLink="/sign-up"><span class="">Sign Up</span></a>
      </li>
      <li class="nav-item active" routerLinkActive="active current">
        <a class="nav-link" routerLink="/login"><span class="">Login</span></a>
      </li>
    </ul>
  </div>
</nav>

当涉及移动设备尺寸时,应该转换为button。实际上确实如此,button对任何点击都没有反应。为什么?有没有人有任何线索?我没有向angular.cli添加任何脚本。

更新: project structure

  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
    "bootstrap": "^4.0.0-beta.2",
    "core-js": "^2.4.1",
    "jquery": "^3.2.1",
    "popper.js": "^1.12.9",
    "rxjs": "^5.4.1",
    "zone.js": "^0.8.14"
  },

1 个答案:

答案 0 :(得分:2)

这是你在.angular-cli.json中应该拥有的东西

"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"
  ],
"styles": [
    "styles.css",
    "../node_modules/bootstrap/dist/css/bootstrap.css"
  ]