我在Angular应用程序中使用bootstrap中的导航栏示例,但导航栏根本没有出现。
这是navbar html
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
我已经安装了bootstrap npm install bootstrap --save
并在styles.css中导入bootstrap @import '~bootstrap/dist/css/bootstrap.css';
请帮助谢谢
答案 0 :(得分:4)
试试这个
- &GT;通过npm install安装bootstrap --save bootstrap
- &GT;在.angular-cli.json中,样式添加"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
将是这样的
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng2-bootstrap/x.x.x/ng2-bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
或添加
<link rel="stylesheet" type="text/css" href="../node_modules/bootstrap/dist/css/bootstrap.min.css"/>
或通过路径 GroupMaster [with columns Id Name]
MemberMaster [with columns Id Name]
MemberGroupMap [with columns Id GroupId [foreign key to group master] MemberId [foreign key to Member master] ]
答案 1 :(得分:0)
没有提到Angular版本,但这不应该像将bootstrap导入添加到app-components.ts或涉及的任何组件打字稿文件一样简单吗?下面是与引导程序相关的三行。
我相信这是通过ng add angular-bootstrap-md
为我完成的import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
MDBBootstrapModule.forRoot(),
FormsModule,
MDBBootstrapModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }