【发布时间】:2018-08-27 20:49:03
【问题描述】:
我开始使用 Angular 动画,但我遇到了这个错误:
错误 DOMException:无法在“元素”上执行“动画”:部分 不支持关键帧。
我尝试用谷歌搜索,但没有成功。
这是我的代码:
app.component.ts:
import { Component } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
animations: [
trigger('square', [
state('normal', style({
background: 'transparent',
border: '2px solid black',
borderRadius : '0px'
})),
state('wild', style({
background: 'red',
border: 'Opx',
borderRadius:'100px'
})),
transition('normal => wild', animate(300))
])
]
})
export class AppComponent {
public currentState: string = "wild";
}
我的 app.component.html:
<div class="container-fluid">
<div class="row">
<button class="btn btn-secondary col-1 mx-auto" (click) = "currentState='normal'"> normal </button>
<button class="btn btn-primary col-1 mx-auto" (click) = "currentState='wild'"> wild </button>
<!--<button class="btn btn-success col-1 mx-auto"> 3 </button>
<button class="btn btn-danger col-1 mx-auto"> 4 </button>-->
</div>
<div class="row">
<div [@square] ="currentState" class="square mx-auto"></div>
</div>
</div>
感谢您的帮助!
【问题讨论】:
标签: angular angular-animations