我已安装最新版本的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
添加任何脚本。
"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"
},
答案 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"
]