本文概述
- 如何安装Angular项目的Bootstrap?
- 如何在项目中添加bootstrap.css文件?
npm install --save bootstrap@3=> The @3is important!

文章图片
此外,当你使用通过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。前导../不得包含在内。

文章图片
在这里,我们使用的是Angular 7.2.3版本。
如何在项目中添加bootstrap.css文件?展开节点模块(库根文件夹)

文章图片
转到bootstrap文件夹并展开它。

文章图片
转到dist文件夹并展开dist。

文章图片
展开css,你将找到“ bootstrap.css”。展开bootstrap.css,你将看到bootstrap.min.css

文章图片
打开angular.json文件,然后在样式部分添加bootstrap.min.css。
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css"
],
现在已为你的Angular 7项目安装了Bootstrap。你现在可以使用它。
推荐阅读
- angular 7中所有的cli命令
- angular 7文件解释
- angular 7第一个app
- angular 7的历史和版本
- angular 7的安装
- angular 7介绍
- angular 7特性
- angular 7入门教程