无法使用ng-bootstrap与Angular 9。

问题描述 投票:0回答:1

这是我的appModule,我使用的是ng-boostsrap的carousel。

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component'; 
import { NgbModule, NgbCarousel } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
   NgbModule,
    NgbCarousel   
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

每当我添加任何ng-bootstrap组件时,它给出了以下错误,这里我添加了carousel。

ERROR in node_modules/@ng-bootstrap/ng-bootstrap/carousel/carousel.d.ts:24:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

    This likely means that the library (@ng-bootstrap/ng-bootstrap) which declares NgbCarousel has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

    24 export declare class NgbCarousel implements AfterContentChecked, AfterContentInit, OnDestroy {
                            ~~~~~~~~~~~

先谢谢你

carousel ng-bootstrap angular9
1个回答
0
投票

每当你的项目已经被服务时,这样的安装就会完成。

  1. 进入CLI
  2. 按CTRL + C
  3. 按Y
  4. 重新保存您的应用程序
  5. 这次的错误应该会消失
© www.soinside.com 2019 - 2024. All rights reserved.