在我的HTML中,我很好奇是否在语义上正确使用唯一标识符,例如<toys> </toys>保存图像而不是图像<h2>.例如:
是否首选:
<toys class="grid_4 push_2"> </toys>
与CSS:
toys {
background: url("toys.png") no-repeat scroll 0 0 transparent;
width: 181px;
height: 93px;
margin-top: -8px;
}
Run Code Online (Sandbox Code Playgroud)
而不是:我目前有:
<h1 class="grid_4 push_2"> </h1>
与CSS:
h1 {
background: url("toys.png") no-repeat scroll 0 0 transparent;
width: 181px;
height: 93px;
margin-top: -8px;
}
Run Code Online (Sandbox Code Playgroud)
是否使用像<toys>语义正确的唯一标识符?
我正在尝试检测是否已注册具有特定名称的自定义元素.有办法进行这样的检查吗?
或者有没有办法获得已注册的自定义元素列表?
我知道document.registerElement,但还有什么?它是单向API吗?
我试图在父组件上添加动画,所以当子组件:enter或:leave时,会显示滑动效果.这是我的父亲@component:
@component({
selector: 'plan',
templateUrl: '../templates/plan.tpl.html',
styleUrls: ['../../../../assets/css/plan.scss'],
animations: [
trigger('stepAnimation', [
transition(':enter', [
style({transform: 'translateX(100%)'}),
animate('0.5s ease-in-out', style({transform: 'translateX(0%)'}))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({transform: 'translateX(0%)'}),
animate('0.5s ease-in-out', style({transform: 'translateX(-100%)'}))
])
])]
})
Run Code Online (Sandbox Code Playgroud)
然后我将动画选择器添加到模板中的子组件,如下所示:
<start *ngIf="currentPage == 'start'" @stepAnimation></start>
<about *ngIf="currentPage == 'about'" @stepAnimation></about>
<family *ngIf="currentPage == 'family'" @stepAnimation></family>
Run Code Online (Sandbox Code Playgroud)
动画不起作用.然后我在每个组件中添加动画代码,并将@stepAnimation添加到每个模板的父标签中.这样,我得到了输入动画,但没有离开.我想这是因为父母的ngIf,但无论如何,有很多重复的动画代码.无论如何都会在父级别上处理动画吗?