Angular教程

Angular Bootstrap

如何为Angular项目安装Bootstrap?

在命令提示符下运行以下命令:
npm install--save bootstrap@3  => The @3  is important!
使用Bootstrap的Angular 7
此外,当您使用通过Angular CLI 6+创建的项目时(通过 ng v ),您将拥有angular.json文件,而不是 .angular-cli.json 文件。在该文件中,您仍然需要将Bootstrap添加到 styles [] 数组中,但是路径应为 node_modules/bootstrap/dist/css/bootstrap.min.css 否 ../node_modules/bootstrap/dist/css/bootstrap.min.css 。不得包含前导 ../。
使用Bootstrap的Angular 7
在这里,我们使用的是Angular 7.2.3版本。

如何在项目中添加bootstrap.css文件?

扩展节点模块(库根文件夹)
使用Bootstrap的Angular 7
转到bootstrap文件夹并展开它。
使用Bootstrap的Angular 7
转到dist文件夹并展开dist。
使用Bootstrap的Angular 7
展开css,您将找到" bootstrap.css"。展开bootstrap.css,您将看到bootstrap.min.css
使用Bootstrap的Angular 7
打开angular.json文件,并在样式部分添加bootstrap.min.css。现在已为Angular 7项目安装了
"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css",
  "src/styles.css"
],
现在可以使用Bootstrap了。

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4