【发布时间】:2020-05-13 01:19:26
【问题描述】:
我想在页面组件加载的时候做一个opacity的效果,但是我发现必须设置一个setTimeout()才能运行成功。
有没有更好的办法?
例如:
组件:
@Component({
selector : 'my-app',
template: `
<div id="component" [ngClass]="{show: block}">
content
</div>
`
})
export class FaderComponent implements OnInit {
block: boolean = false
constructor(){}
ngOnInit() {
setTimeout(()=>{
this.block = true;
},100)
}
}
scss:
#component {
opacity: 0;
transition: 0.4s;
&.show{
opacity: 1;
}
}
【问题讨论】:
-
这个框架有一个动画模块:angular.io/guide/animations阅读这个指南。
标签: html angular typescript angular-animations