无法使用 ng 命令在 angular 中添加 ng-bootstrap
Unable to add ng-bootstrap in angular using ng command
我是 angular 的新手,使用的是 12.1.4 版本。我无法在 angular 中添加或安装 bootstrap 依赖项。当我 运行 在 cmd 提示符下命令时。
ng add @ng-bootstrap/ng-bootstrap
然后它抛出一个错误,如下图所示:
在您的 angular 12
应用中安装 bootstrap
,如下所示。这仅适用于 css
导入。
npm install bootstrap --save
现在您需要像这样直接在 style.css
文件中导入 bootstrap css
:
@import "~bootstrap/dist/css/bootstrap.css";
但是,如果您需要使用 jquery
和 popper js
安装 bootstrap
,则 运行 如下命令:
npm install bootstrap --save
npm install jquery --save
npm install popper.js --save
成功后 运行 上述命令将其导入 angular.json
文件中,如下所示:
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
我是 angular 的新手,使用的是 12.1.4 版本。我无法在 angular 中添加或安装 bootstrap 依赖项。当我 运行 在 cmd 提示符下命令时。
ng add @ng-bootstrap/ng-bootstrap
然后它抛出一个错误,如下图所示:
在您的 angular 12
应用中安装 bootstrap
,如下所示。这仅适用于 css
导入。
npm install bootstrap --save
现在您需要像这样直接在 style.css
文件中导入 bootstrap css
:
@import "~bootstrap/dist/css/bootstrap.css";
但是,如果您需要使用 jquery
和 popper js
安装 bootstrap
,则 运行 如下命令:
npm install bootstrap --save
npm install jquery --save
npm install popper.js --save
成功后 运行 上述命令将其导入 angular.json
文件中,如下所示:
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]