Angular 7 - 错误错误:未捕获(在承诺中):TypeError:无法读取未定义的属性“forEach”
2020-03-11
603
当我在 component.ts 中设置动画时,我没有收到任何错误。但是,当将动画导出到单独的文件时,我收到如下所示的错误。
animations.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)),
])
]);
component.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]
})
1个回答
问题是我导出了一个数组。当分别导出每个触发器时,它就可以正常工作了!
A.Ashley
2020-03-11