angular怎么集成bootstrap4?方法介绍


本文摘自PHP中文网,作者青灯夜游,侵删。

本篇文章给大家介绍一下angular中集成bootstrap4的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

相关教程推荐:《angularjs视频教程》、《bootstrap教程》

angular集成bootstrap4

1、打开终端,输入命令新建一个angular app

1

ng new app

2、集成bootstrap

安装ngx-bootstrapBootstrap

在新建的项目中打开终端,运行如下命令

1

npm install ngx-bootstrap bootstrap --save

3、使用bootstrap样式

配置项目:必须将项目其配置为包括Bootstrap CSS,才能使用bootstrap的样式。

在angular.json中增加bootstrap的样式:从项目的根目录打开文件angular.json,找到Style配置项,指定bootstrap.min.css的路径。完成后,它应如下所示:

1

2

3

4

"styles": [

              "src/styles.sass",

              "./node_modules/bootstrap/dist/css/bootstrap.min.css"

            ],

注意:对angular.json进行更改时,您将需要重新启动ng服务以获取配置更改。

4、在app.module.ts中引入要使用的ngx-bootstrap module

打开src/app/app.module.ts 并添加想要使用的组件module,例如BsDropdownModule.forRoot()

1

2

3

4

5

6

7

8

import { BsDropdownModule } from 'ngx-bootstrap/dropdown';

...

 

@NgModule({

   ...

   imports: [BsDropdownModule.forRoot(), ... ],

    ...

})

具体使用哪个bootstrap组件,点击https://valor-software.com/ngx-bootstrap/#/documentation查看

更多编程相关知识,请访问:编程教学!!

以上就是angular怎么集成bootstrap4?方法介绍的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

bootstrap学习之表单格式与字体图标

Angular开发者必须学习的19件事

bootstrap 不支持ie怎么办

bootstrap有必要学吗

bootstrap怎么实现自适应高度

分享Angular中关于表单的一些知识点

bootstrap input样式修改的方法

rocketbootstrap是什么

bootstrap主要是什么

什么是bootstrap框架?

更多相关阅读请进入《Angular》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...