javascript - Angular 7 - 错误错误 : Uncaught (in promise): TypeError: Cannot read property 'forEach' of undefined

标签 javascript angular

当我在 component.ts 中设置动画时,我没有收到任何错误。但是,当将动画导出到单独的文件时,我收到如下所示的错误。

动画.ts

import { trigger, state, transition, style, animation, animate } from '@angular/animations';

export const transAnimation = animation([
  trigger('fade', [
    state('void', style({ opacity: 0 })),
    transition(':enter', [
      animate(300)
    ])
  ]),
  trigger('fadeOut', [
    state('void', style({ opacity: 0 })),
    transition(':leave', [
      animate(300)
    ])
  ]),
  trigger('shake', [
    state('false', style({ transform: 'translateX(10px)' })),
    transition('0 => 1', [
      animate(300)
    ])
  ]),
  trigger('slideIn', [
    state('void', style({ transform: 'translateX(10px)' })),
    transition(':enter', [
      animate(300)
    ])
  ]),
  trigger('hideShow', [
    state('false', style({ opacity: 0 })),
    transition('0 => 1', animate(300)),
  ])
]);

组件.ts

import { transAnimation } from '../../animations';
[enter image description here][1]
@Component({
  selector: 'app-card-update',
  templateUrl: './card-update.component.html',
  styleUrls: ['./card-update.component.scss'],
  animations: [transAnimation]
})

最佳答案

问题是我正在导出一个数组。单独导出每个触发器时它可以工作!

关于javascript - Angular 7 - 错误错误 : Uncaught (in promise): TypeError: Cannot read property 'forEach' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60634537/

相关文章:

angular - 当 Angular 2 中显示微调器组件时,如何使 div 透明/禁用

javascript - 如何跟踪 Backbone.js 中的路由器更改事件

html - 调用属于 ngFor 一部分的子组件上的函数

javascript - Slim 中的 onclick 事件不起作用 - 将 ' 转换为 &#x27

javascript - 下划线包含从头开始?

Electron 打印中的 Angular 应用程序构建 div 显示空白窗口

javascript - 如何比较和过滤es6中两个对象数组中不匹配的数组

html - ngx-bootstrap:可使用模板排序(水平)

javascript - 填写 PDF 表格

javascript - React Hook Form 将复选框设置为选中状态