ionic-framework - Ionic 4 将参数传递到另一个页面
问题描述
请帮助如何将参数传递到ionc 4中的另一个页面?
正如在 ionic4 中看到的 push 和 navparam 函数不再起作用一样。
https://medium.com/@muthudevendra/ionic-sharing-data-between-pages-8d0412cb8f58
解决方案
Page1.ts
public country: string;
public email: string;
public password: string;
constructor(public nav: NavController) {}
goToAboutPage() {
let params: any = {
country: this.country,
email: this.email,
password: this.password
}
this.nav.navigateForward('/identity', { state: params }); // params to pass object/array
}
Page2.ts
constructor(public router: Router){
if (router.getCurrentNavigation().extras.state) {
const params = this.router.getCurrentNavigation().extras.state;
console.log(params.email)
console.log(params.password)
console.log(params.country)
}
}
推荐阅读
- c++ - 如何 I\O 位于 MPI 共享内存区域的二维数组?
- angular - 使用 rxjs 对一系列可观察对象的链式订阅
- reactjs - 如何告诉 React 使用另一个索引
- javascript - Angular 仅在我指定 app.get("*"[...]); 时才有效 在我的 server.js 中
- powerdesigner - 如何在powerdesigner中保留某些代码区域?
- javascript - 使用有向排序方法,是否可以确定同一层次结构中节点的相对位置?
- css - 内容不可用时如何优雅地回退
- android - 从 edittext 状态更改按钮文本
- powershell - PDFTK 与 Powershell 和 Move-Item 到父目录
- django - dockerize gunicorn, nginx, django 在单个容器中