首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将BrowserAnimationsModule或NoopAnimationsModule添加到独立组件中?

如何将BrowserAnimationsModule或NoopAnimationsModule添加到独立组件中?
EN

Stack Overflow用户
提问于 2022-06-05 01:14:10
回答 3查看 940关注 0票数 5

当我将BrowserAnimationsModuleNoopAnimationsModule添加到独立AppComponent的imports数组中时,它会破坏应用程序。

代码语言:javascript
运行
复制
@Component({
  standalone: true,
  imports: [
    CommonModule,
    NoopAnimationsModule,
    /* ... */
  ],
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})

以下是我在添加任何一个错误时所遇到的错误:

代码语言:javascript
运行
复制
ERROR Error: Uncaught (in promise): Error: Providers from the `BrowserModule` have already been loaded.
If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.

Error: Providers from the `BrowserModule` have already been loaded.
If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.

当我不加它的时候,我会得到这个错误:

代码语言:javascript
运行
复制
ERROR Error: Unexpected synthetic property @transitionMessages found. Please make sure that:
 - Either `BrowserAnimationsModule` or `NoopAnimationsModule` are imported in your application.
 - There is corresponding configuration for the animation named `@transitionMessages` defined in
 the `animations` field of the `@Component` decorator (see
 https://angular.io/api/core/Component#animations).
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72504142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档