简体   繁体   English

如何启用Angular动画?

[英]How to enable Angular animations?

I've done everything by the tutorial ( https://angular.io/guide/animations ), but I have the error: menu-navigation.component.html:1 ERROR Error: Found the synthetic property @slideTop. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. 我已经通过教程( https://angular.io/guide/animations )完成了所有工作,但我有错误: menu-navigation.component.html:1 ERROR Error: Found the synthetic property @slideTop. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. menu-navigation.component.html:1 ERROR Error: Found the synthetic property @slideTop. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

I read everything about it but did not find the answer on how to resolve it. 我阅读了有关它的一切,但没有找到解决方法的答案。

Files: 文件:

So I did: 所以我做了:

  • Imported animation modules in the root module (and added them into imports section) 根模块中导入的动画模块(并将它们添加到导入部分)
  • Described animation of the animated element 描述动画元素的动画
  • Defined attribute about animation 关于动画的定义属性
  • Did everything according to documentation 根据文件做了一切

I tried: 我试过了:

  • Replace BrowserAnimationsModule with NoopAnimationsModule: no result 用NoopAnimationsModule替换BrowserAnimationsModule:没有结果
  • Replace "data: boolean" with "data: any" (in parent component): no result 将“data:boolean”替换为“data:any”(在父组件中):无结果
  • Check all NPM-modules versions: they are all 8.0.0 version, no result 检查所有NPM模块版本:它们都是8.0.0版本,没有结果
  • Check tutorial steps many times: no result 多次检查教程步骤:没有结果
  • Copy animation metadata from the tutorial and do everything like there, and still: no result 复制教程中的动画元数据并执行所有操作,但仍然:没有结果

Guys, help me :) I am stuck for already a few days. 伙计们,帮帮我:)我已经被困了几天了。

UPDATE: Finally, I found the answer after testing on a new empty project 更新: 最后,我在测试一个新的空项目后找到了答案

If you defined "animations" to the component (prop), then you can use them only inside its component (its own html), but not within a parent layout. 如果您为组件(prop)定义了“动画”,那么您只能在其组件(它自己的html)中使用它们,但不能在父布局中使用它们。

Instead of "" you must move its amination inside that component (app-animated-comp). 而不是“”你必须在该组件内移动它的aamin(app-animated-comp)。

BrowserAnimationsModule is an package you need to add in your app.module BrowserAnimationsModule是您需要在app.module中添加的软件包

https://material.angular.io/guide/getting-started https://material.angular.io/guide/getting-started

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

@NgModule({
  ...
  imports: [BrowserAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM