在ionic 5中的页面之间传递数据 [英] Pass the data between pages in ionic 5
本文介绍了在ionic 5中的页面之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 ionic 版本 5 中的页面之间传递一些数据.有什么可能的方法吗?我使用的是离子版本5.4.16"和角度版本10.0.8".
I want to pass some data between the pages in ionic version 5. Is there any possible way to do this? I am using ionic version '5.4.16' and angular version '10.0.8'.
推荐答案
Page 1
constructor(public nav: NavController){}
pushToNextScreenWithParams(pageUrl: any, params: any) {
this.nav.navigateForward(pageUrl, { state: params });
}
第 2 页
constructor(public router: Router){
if (router.getCurrentNavigation().extras.state) {
const pageName = this.router.getCurrentNavigation().extras.state;
console.log(pageName)
}
}
这篇关于在ionic 5中的页面之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文