首页 > 解决方案 > Angular 应用程序中的引导程序 5

问题描述

自第 5 版以来, Bootstrap框架已将jQuery作为一项要求移除。

我想知道此更改如何影响 Angular 应用程序?

我们可以在 Angular 中使用所有提供的引导功能(例如下拉菜单)吗?

我知道 Angular 不应该与 JQuery 结合使用——在早期版本的 Bootstrap 中,如果我们想使用所有引导功能,建议导入 JQuery,这很糟糕。

但是 Bootstrap 5 不再依赖 JQuery,所以在我的 Angular 应用程序中使用它是否安全?

至于现在我不想使用像 ng-bootstrap 这样的引导替代品,这就是为什么我要问在 Angular 中使用 Bootstrap 5是否可以且安全?

标签: javascriptjqueryangulartwitter-bootstrapbootstrap-5

解决方案


安装引导程序只需使用

npm install bootstrap

并编辑 angular.json 文件

        "styles": [
          "node_modules/bootstrap/dist/css/bootstrap.min.css", //<--add this line
          "src/styles.css"
        ],
        "scripts": [
          "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" //<--and this line
        ]

推荐阅读