我用Angular -seed升级了一个Angular 4项目,现在得到了这个错误

找到合成属性@panelState。请在应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。

我该如何解决这个问题?错误消息到底告诉我什么?


当前回答

我要做的就是安装这个

npm install @angular/animations@latest --save  

然后导入

import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 

到你的app.module.ts文件。

其他回答

我的问题是@angular/platform-browser的版本是2.3.1

npm install @angular/platform-browser@latest --save

升级到4.4.6,在node_modules/@angular/platform-browser下添加了/animations文件夹

我要做的就是安装这个

npm install @angular/animations@latest --save  

然后导入

import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 

到你的app.module.ts文件。

动画应该应用在特定的组件上。

在其他组件中使用动画指令,并在另一个组件中提供。

CompA——@Component ({



动画:[动画] }) CompA——@组件 ({



动画:[animation] <===这应该在used component中提供 })

我得到以下错误:

Found the synthetic property @collapse. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

我遵循Ploppy接受的答案,它解决了我的问题。

以下是步骤:

1.
    import { trigger, state, style, transition, animate } from '@angular/animations';
    Or 
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

2. Define the same in the import array in the root module.

它将解决错误。编码快乐! !

一个简单的解决方案是,不要在你的lazyloaded或子模块中导入BrowserAnimationsModule,只在你的AppModule中导入。如果在运行组件测试时遇到相同的错误,请将其添加到测试平台的导入数组中。请注意。如果你没有自己定义的动画,这是可行的