javascript - 动画不是离子中的构造函数
问题描述
我想调整 toastAlert 的动画,但它显示错误我在@ionic/core 中使用动画,我的离子版本是 ionic v5 可能是版本问题,但我不知道如何解决,确实任何人都可以帮助我吗?
ERROR Error: Uncaught (in promise): TypeError: AnimationC is not a constructor
TypeError: AnimationC is not a constructor
这里是customAlertEnter.ts
import { Animation } from '@ionic/core'
export function customAlertEnter(AnimationC: Animation, baseEl: HTMLElement): Promise<Animation> {
const baseAnimation = new AnimationC();
const backdropAnimation = new AnimationC();
backdropAnimation.addElement(baseEl.querySelector('ion-backdrop'));
const wrapperAnimation = new AnimationC();
const wrapperElem = baseEl.querySelector('.alert-wrapper') as HTMLElement;
wrapperAnimation.addElement(wrapperElem);
wrapperElem.style.top = '0';
backdropAnimation.fromTo('opacity', 0.01, 0.3);
wrapperAnimation.beforeStyles({ 'opacity': 1 });
wrapperAnimation.fromTo('transform', `translateY(-${baseEl.clientHeight}px)`, 'translateY(0px)')
return Promise.resolve(baseAnimation
.addElement(baseEl)
.easing('cubic-bezier(.36, .66, .3, .1, 1)')
.duration(500)
.add(wrapperAnimation)
.add(backdropAnimation));
}
这是代码showAlert()
async showAlert(message: string){
const alert = await this.toastController.create({
message: message,
duration: 2000,
position: 'top',
enterAnimation: customAlertEnter
})
谢谢!
解决方案
推荐阅读
- typescript - 使用 Typescript 限制上传文件的大小和类型
- android - 如何将 SDK 放入 JFrog 神器?
- windows - 一键从Windows发送魔术包
- netcat - nmap/netcat 区分没有服务监听的开放端口和有服务监听的开放端口
- c# - 尝试在多个域上使用 Azure AFDS 登录
- python - Pygame子弹和玩家有时对角线不对齐
- excel - 如何在 Excel 中确定哪种订单组合是最佳的?
- reactjs - React 的 MS Graph API 问题
- kotlin - 在 kotlin 中构建项目时出现错误
- laravel - Laravel - 找不到驱动程序