角度材质 sidenav 错误找到了合成监听器@transform.start

Sne*_*l P 6 angular-material material-ui angular

https://stackblitz.com/github/snehalp29/ng10-material10

我正在尝试使用材料侧导航,但遇到以下问题。

Preview-29b0f46fcc27b310236ab.js:1 错误错误:未捕获(承诺中):错误:找到合成侦听器 @transform.start。请在您的应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。错误:找到合成侦听器@transform.start。请在您的应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。

下面是代码

<mat-sidenav-container class="example-container">
  <mat-sidenav mode="side" opened>
    Sidenav content
    <app-toolbar></app-toolbar>
  </mat-sidenav>
  <mat-sidenav-content
    >Main content
    <router-outlet></router-outlet>
  </mat-sidenav-content>
</mat-sidenav-container>

Run Code Online (Sandbox Code Playgroud)

小智 4

抛出的错误告诉我们您必须在模块中包含模块“BrowserAnimationsModule”或“NoopAnimationsModule”。

如果您的模块是AppModule,则必须包含Angular Material所需的导入,例如:

@NgModule({
  declarations: [...],
  imports: [
    others imports here...,
    BrowserAnimationsModule <---- the import required!
  ]
})
Run Code Online (Sandbox Code Playgroud)

尝试一下