angular - 将 Bootstrap 4 添加到 Angular 6 或 Angular 7 应用程序
问题描述
我正在使用 bootstrap 4 开发 Angular 应用程序。
我需要有关在我的角度应用程序中添加 scss 的帮助。
我的问题是:
- 在 Angular 6 和 Angular 7 中添加 bootstrap 4 scss 的方式是否相同?
IE
npm install bootstrap --save
并且,打开 angular.json 文件并将引导文件路径添加到样式部分。喜欢:
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
上述方式对于两个版本的角度是否相同。
解决方案
您需要执行以下操作:
将 Bootstrap 添加到package.json
(使用 npm install bootstrap --save 完成)
将 Bootstrap 添加到angular.json
(也需要 jQuery)
"styles": [
"styles.css".
"../node_modules/bootstrap/dist/css/bootstrap.min.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 应用程序中引用 Bootstrap (app.module.ts)
import bootstrap from "bootstrap";
演示:https
://codesandbox.io/s/kmm2q7zvko
文章:https ://medium.com/wdstack/angular-7-bootstrap-4-starter-25573dff23f6
推荐阅读
- string - 读取从 httpclient.sendasync 返回的内容
- java - 执行 kafka-console-consumer.sh 时,zookeeper 不是一个公认的选项
- java - Java 8 - 通配符扩展,BiPredicate 不起作用
- node.js - 在 Heroku 上使用 facebook 身份验证
- python - 删除不需要的字符和编辑熊猫中的列名
- ios - 如何在侧边栏中设置与所有其他行不同的表格视图单元格的第一行 - swift
- fortran - 我在 fortran 中读取 txt 文件时得到奇怪的输出
- javascript - Javascript - 将 json 对象数组值更改为多个字符串
- html - SVG 使用 CSS 更改填充颜色
- javascript - 我们如何更改按钮以选择选项