您现在的位置:首页 >> 前端 >> 内容

Angular5及Bootstrap4结合使用示例(代码)

时间:2018/2/3 11:21:40 点击:

  核心提示:前段时间Bootstrap发布4.0正式版。如何将Angular5与Bootstrap4结合使用呢?使用Angular-cli初始化项目。ng new my-project --style=scss安...

前段时间Bootstrap发布4.0正式版。

如何将Angular5与Bootstrap4结合使用呢?

使用Angular-cli初始化项目。

ng new my-project --style=scss

安装Bootstrap及需要的依赖 npm i bootstrap jquery popper.js --save-dev;

如果想使用字体图标需要另引入,比如fontawesome

npm i font-awesome --save-dev

在angular-cli.json中引入js文件:

"scripts": [
  "../node_modules/jquery/dist/jquery.js",
  "../node_modules/popper.js/dist/umd/popper.js",
  "../node_modules/bootstrap/dist/js/bootstrap.js"
],

引入样式文件style.scss中:

@import "~bootstrap/scss/bootstrap";
// 定义图标路径
$fa-font-path: "../node_modules/font-awesome/fonts";
@import "../node_modules/font-awesome/scss/font-awesome.scss";

剩下的就是可以自由发挥了

Tags:AN NG GU UL 
作者:网络 来源:justforuse