首页 > 解决方案 > 为什么动画在 Angular 5 应用程序中不起作用?

问题描述

我正在尝试在 Angular 5 应用程序中开发第一个动画,但它不起作用。到目前为止我所做的详细说明:

  1. app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
   imports: [
      BrowserModule,
      ...
      BrowserAnimationsModule,
      ...

在我的组件中:

import { trigger,style,transition,animate,keyframes,query,stagger } from '@angular/animations';

animations: [

      trigger('slideOut', [
          transition('* => void', [
            style({height: '*'}),
            animate('2000ms ease-out', style({height: 0})),
          ])
        ])

    ]

这是模板:

 <div [@slideOut] class="alert alert-success alert-dismissible fade in" role="alert">
    <button type="button" class="close"><span aria-hidden="true">&times;</span></button>
        <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
    All is good!
</div>

知道我在这里缺少什么吗?我需要安装一些东西吗?

标签: angularangular-animations

解决方案


推荐阅读