gpt4 book ai didi

popover - 从其组件中关闭 Ionic 4 popover

转载 作者:行者123 更新时间:2023-12-04 05:11:25 28 4
gpt4 key购买 nike

我有一个标准的 Ionic 4 页面(主页),它创建一个使用组件(BusinessDetails)和一个重定向到新页面(RequestTurn)的按钮的弹出窗口。但是,当我单击该按钮时,弹出窗口不会消失,而是呈现在我的 RequestTurn 页面顶部。我想我需要从组件 (BusinessDetails) 中手动关闭它,但我不知道如何从那里访问 popover 的实例,因为它是在主页中创建的。有没有办法做到这一点?

主页.ts

presentModal(business:Business, event: Event) {
this.popoverController.create(({
component: BusinessDetailsComponent,
cssClass: "business-popover",
showBackdrop: true,
componentProps: {
business: business
}
}) as any).then(popover => popover.present()); }

业务详细信息.component.ts
goToRequestTurn(id: string) {
//Need to dismiss popver here (?)
this.router.navigateByUrl(`/request-turn/${id}`); }

谢谢你的帮助。

最佳答案

添加 private popoverController: PopoverController到组件构造函数

然后写一个这样的函数,当你想关闭模态时调用它

 async DismissClick() {
await this.popoverController.dismiss();
}

关于popover - 从其组件中关闭 Ionic 4 popover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55009251/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com