关于angular:angular集成bootstrap4

2次阅读

共计 681 个字符,预计需要花费 2 分钟才能阅读完成。

1、关上终端,输出命令新建一个 angular app

ng new app

2、集成 bootstrap
装置 ngx-bootstrapBootstrap
在新建的我的项目中关上终端,运行如下命令

npm install ngx-bootstrap bootstrap --save

3、应用 bootstrap 款式
配置我的项目:必须将我的项目其配置为包含 Bootstrap CSS,能力应用 bootstrap 的款式。

在 angular.json 中减少 bootstrap 的款式:从我的项目的根目录关上文件 angular.json,找到 Style 配置项,指定 bootstrap.min.css 的门路。实现后,它应如下所示:

"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 并增加

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

@NgModule({
   ...
   imports: [BsDropdownModule.forRoot(), ... ],
    ...
})

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

正文完
 0