我用Angular -seed升级了一个Angular 4项目,现在得到了这个错误
找到合成属性@panelState。请在应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
我该如何解决这个问题?错误消息到底告诉我什么?
我用Angular -seed升级了一个Angular 4项目,现在得到了这个错误
找到合成属性@panelState。请在应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
我该如何解决这个问题?错误消息到底告诉我什么?
当前回答
一个简单的解决方案是,不要在你的lazyloaded或子模块中导入BrowserAnimationsModule,只在你的AppModule中导入。如果在运行组件测试时遇到相同的错误,请将其添加到测试平台的导入数组中。请注意。如果你没有自己定义的动画,这是可行的
其他回答
我要做的就是安装这个
npm install @angular/animations@latest --save
然后导入
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
到你的app.module.ts文件。
针对angularJS 4的更新:
(SystemJS) XHR错误(404 Not Found)加载http://localhost:3000/node_modules/@angular/platform-browser/bundles/platform-browser.umd.js/animations
解决方案:
**cli:** (command/terminal)
npm install @angular/animations@latest --save
**systemjs.config.js** (edit file)
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
**app.module.ts** (edit file)
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
imports: [ BrowserModule,BrowserAnimationsModule ],
...
试试这个
NPM install @angular/animations@latest
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
这对我很有用。
我的问题是@angular/platform-browser的版本是2.3.1
npm install @angular/platform-browser@latest --save
升级到4.4.6,在node_modules/@angular/platform-browser下添加了/animations文件夹
当我尝试使用BrowserAnimationsModule时,我遇到了类似的问题。以下步骤解决了我的问题:
删除“node_modules”目录 使用npm cache clean清除你的包缓存 运行这里列出的两个命令中的一个来更新现有的包
如果你遇到404错误
http://.../node_modules/@angular/platform-browser/bundles/platform-browser.umd.js/animations
在system.config.js中添加以下条目:
'@angular/animations': 'node_modules/@angular/animations/bundles/animations.umd.min.js',
'@angular/animations/browser':'node_modules/@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations': 'node_modules/@angular/platform-browser/bundles/platform-browser-animations.umd.js'
Naveedahmed1提供了这个github问题的解决方案。