问题描述
我已经使用以下 npm 命令在 Angular 10 项目中安装了 ngx bootstrap,我在我的 Angular 中使用了 scss
npm i ngx-bootstrap
但是安装后,当我在这里使用引导代码时,它无法正常工作。我该如何解决这个问题?
解决方法
您将需要引导程序样式:
<!--- 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
,使用 Angular CLI ng add 命令更新您的 Angular 项目。
ng add ngx-bootstrap
或者使用 ng add 添加需要的组件(例如工具提示)。
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>