Bootstrap 5 导航栏确实扩展了,但在 Angular 项目上没有关闭
我正在使用 Angular 12 和 Bootstrap 5 创建 SPA。我创建了一个共享导航栏组件。当我的导航栏更改为汉堡菜单按钮时,导航栏确实按预期折叠。但是当我尝试关闭它时,没有任何反应。我错过了什么吗?
<nav class="navbar fixed-top navbar-expand-md navbar-dark shadow">
<div class="container-fluid">
<a class="navbar-brand" routerLink="/someUrl">Foo</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarToggleContent"
aria-controls="navbarToggleContent"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggleContent">
<ul class="navbar-nav ms-auto">
<li class="nav-item p-2">
Item 1
</li>
<li class="nav-item p-2">
Item 2
</li>
<li class="nav-item p-2">
Item 3
</li>
</ul>
</div>
</div>
</nav>
I am using Angular 12 and Bootstrap 5 to create a SPA. I created a shared navbar component. When my navbar changes to the hamburger menu button, the navbar does collapse as intended. But when i try to close it, there is no reaction. Am i missing something?
<nav class="navbar fixed-top navbar-expand-md navbar-dark shadow">
<div class="container-fluid">
<a class="navbar-brand" routerLink="/someUrl">Foo</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarToggleContent"
aria-controls="navbarToggleContent"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggleContent">
<ul class="navbar-nav ms-auto">
<li class="nav-item p-2">
Item 1
</li>
<li class="nav-item p-2">
Item 2
</li>
<li class="nav-item p-2">
Item 3
</li>
</ul>
</div>
</div>
</nav>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码很好。我忘记将 popper.js 条目添加到我的 angular.json 文件中。
This code is fine. I forget to add the popper.js entry to my angular.json file.