首页 > 解决方案 > 单击按钮后如何在 Ionic 5 上添加动画?

问题描述

我的代码如下,但它不起作用,我想要的是在单击按钮后激活效果。//TS

@ViewChild('icono', { read: ElementRef })icono: ElementRef;

execEffect() {
    let x = this.icono
    x.nativeElement.classList.add('bounce')
}

//HTML

<img #icono src="../../assets/something.png" style="width:60px;" (click)="execEffect()"/>

标签: cssionic5

解决方案


我建议你使用渲染器 2...

我做了四个你的例子...

https://stackblitz.com/edit/angular-ivy-bsqd5d


推荐阅读