Bootstrap 引导导航栏折叠不适用于Angular 4.4.4

zbq4xfa0  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(155)

当我在angular4.4.4中使用bootstrap3时,引导导航栏折叠不起作用,当我点击它时,折叠的内容不显示。谁能帮助我?

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <a class="navbar-brand" href="#" >
            <img src="/assets/brand/apple-touch-icon.png" width="20" height="20" class="d-inline-block align-top" alt="">
            CottonSoft
        </a>
        <button type="button" class="navbar-toggle navbar-toggler-right" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a href="#">Link</a></li>
                <li class="dropdown" dropdown>
                    <a dropdownToggle class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul *dropdownMenu class="dropdown-menu" role="menu">
                        <li role="menuitem"><a href="#">Action</a></li>
                        <li role="menuitem"><a href="#">Another action</a></li>
                        <li role="menuitem"><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li role="menuitem"><a href="#">Separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
bakd9h0s

bakd9h0s1#

执行

npm install  bootstrap --save
npm install jquery --save

在您的项目中/. angular-cli.json
添加以下行:

"styles": [
    "styles.css",
    "../node_modules/bootstrap/dist/css/bootstrap.min.css"
  ],
  "scripts": [
    "../node_modules/jquery/dist/jquery.min.js",
    "../node_modules/bootstrap/dist/js/bootstrap.min.js"
  ],

相关问题