【问题标题】:How to install bootstrap ngx in Angular 10 using NPM如何使用 NPM 在 Angular 10 中安装引导 ngx
【发布时间】:2021-03-05 03:33:37
【问题描述】:

我已经使用以下 npm 命令在 Angular 10 项目中安装了 ngx bootstrap,我在我的 Angular 中使用 scss

npm i ngx-bootstrap

但安装后,当我在这里使用引导代码时,它无法正常工作。我该如何解决这个问题?

【问题讨论】:

    标签: angular sass ngx-bootstrap


    【解决方案1】:

    您将需要引导样式:

    <!--- index.html -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    

    将所需的包添加到 NgModule 导入中:

    import { TooltipModule } from 'ngx-bootstrap/tooltip';
    
    @NgModule({
      ...
      imports: [TooltipModule.forRoot(),...]
      ...
    })
    

    https://www.npmjs.com/package/ngx-bootstrap

    【讨论】:

      【解决方案2】:

      使用 Angular CLI ng add 命令更新您的 Angular 项目。

      • ng add ngx-bootstrap

      或者使用 ng add 添加需要的组件(例如 tooltip)。

      • ng add ngx-bootstrap --component tooltip

      向您的页面添加组件:

      <button type="button" class="btn btn-primary"
              tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
        Simple demo
      </button>
      

      【讨论】:

        猜你喜欢
        • 2015-08-09
        • 2017-06-06
        • 2017-11-09
        • 2020-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-19
        • 2016-04-07
        相关资源
        最近更新 更多