javascript - 无法处理通过 Ionic 4 中 modal.onDidDismiss() 捕获的数据
问题描述
在使用 modal.onDidDismiss()
方法将其关闭后,我成功地从模态页面捕获数据(对象),但我无法处理和显示它:
export class AbracadabrasyPage {
private fastFood: any;
Menus: any[];
Horaires: any[];
Category: string;
constructor(public modalController: ModalController, private routerOutlet: IonRouterOutlet)
{
console.log(this.fastFood); // it displays in the console : Undefined //
this.Menus = this.fastFood.menus;
this.Horaires = this.fastFood.horaires;
this.Category = this.fastFood.cat
};
async onLOcate(){
const modal = await this.modalController.create({
component: MapPage,
swipeToClose: true,
componentProps: {
Lat: this.fastFood.latitude,
Lng: this.fastFood.longitude
},
presentingElement: this.routerOutlet.nativeEl
});
modal.present();
const { data } = await modal.onDidDismiss();
if(data){
this.fastFood = data;
console.log(this.fastFood);
};
};
解决方案
推荐阅读
- markdown - 来自 Contentful 的文本作为一个单独的段落出现
- php - 无法使用相同的表单使用 php 和 ajax 调用插入和更新
- memory-management - 我无法解释这个图:“内存泄漏”与否?
- ruby-on-rails - 在不同端口上运行多个 Rails 应用程序的问题
- python - 如何修复“元组”对象没有“层”属性?
- ios - UITableView - reloadRows 方法创建奇怪的滚动错误
- ramda.js - 如何改进我编写的 ramda 代码?
- c# - 多个 DbContexts 但在使用 Azure DevOps 部署时只有一个在运行
- vagrant - 无法通过 192.168.10.10 访问 Windows 10 上的 Homestead
- powershell - 如何安装 AzureAD PowerShell 模块