当我在 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/