【发布时间】:2019-07-12 01:00:53
【问题描述】:
我尝试了一个简单的动画,使用 @angular/animations 模块让欢迎文本再次淡入淡出。 淡入效果(:enter 过渡)工作得很好,但 :leave 过渡不会触发。我不明白为什么它不起作用。请帮忙:)
我尝试了两种定义转换的方法(':leave' 或 '* => void'),但没有任何效果。
@Component({
selector: 'app-welcome',
templateUrl: './welcome.component.html',
styleUrls: ['./welcome.component.css'],
animations: [
trigger('fade', [
transition(':enter', [
style({ opacity: 0 }),
animate(4000, style({ opacity: 1 })),
]),
transition(':leave', [
animate(4000, style({ opacity: 0 }))
])
]),
]
})
export class WelcomeComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
欢迎文本应该在几秒钟后淡入并在几秒钟后再次淡出。淡入作品,不淡出。
模板:
<div class="container-fluid">
<div class="row justify-content-center">
<span class="font-weight-bold" @fade style="font-size:6vw;"> W E L C O M E !</span>
</div>
【问题讨论】:
标签: angular animation transition