Ionic 2 push() 方向:'back' 选项无法正常运行
Ionic 2 push() direction: 'back' option not functioning properly
1 我有一个包含选项列表的产品页面。
2 单击后,将打开一个新页面,其中列出了所有选项。
3 当我单击某个选项时,例如 'black',我希望页面返回到产品,但使用新选项更新页面 select编辑。这看起来有效,但我无法滚动或 select 页面上的任何内容。
(出于某种原因,产品变体页面显示在新产品页面之上,这就是为什么我无法 select 任何内容或滚动)
4 当我尝试再次返回产品列表页面时,我发现一团糟。
查看
<ion-item *ngFor="#option of productData">
<ion-label>{{option.val}}</ion-label>
<ion-radio (click)="goToProduct($event, option.catalogId)" [checked]="option.val == selected"></ion-radio>
</ion-item>
函数
goToProduct(event, catalogId) {
this.nav.push(ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
我认为我需要删除旧的产品页面,所以我在做:
goToProduct(event, catalogId) {
this.nav.remove(1);
this.nav.push(ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
像这样的各种变体,但没有任何效果。
我知道 Ionic 2 仍处于测试阶段,这是一个已知问题吗?或者我错过了什么?我怎样才能 select 一个选项并使更新的页面方向向后移动而不破坏我的应用程序?
如果我使用 insert()
而不是 push()
,它会根据需要返回到更新的产品,并完全删除旧的产品页面。阅读文档时我没想到会出现这种行为,但我想这是一个不错且简单的解决方案。
goToProduct(event, catalogId) {
this.nav.insert(1, ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
感谢楼上的回答,对我帮助很大
我需要应用我的应用程序页面的 转换 我已经完成了这个但是有一个问题 -
- 每当我回来时,它在某个时间点 重叠 某个页面。
- 经过一番搜索,我解决了这个问题。
这是我的代码-
goBack() {
{
this.nav.insert(0,MyPage, {
PId: this.parentId
},{direction: 'back'});
}
{
this.nav.pop();
}
}
我们也可以根据需要使用{direction: 'forward'}
。
我刚刚将 1 替换为 0 参数并为我工作。
祝你有愉快的一天!!!
1 我有一个包含选项列表的产品页面。
2 单击后,将打开一个新页面,其中列出了所有选项。
3 当我单击某个选项时,例如 'black',我希望页面返回到产品,但使用新选项更新页面 select编辑。这看起来有效,但我无法滚动或 select 页面上的任何内容。
(出于某种原因,产品变体页面显示在新产品页面之上,这就是为什么我无法 select 任何内容或滚动)
4 当我尝试再次返回产品列表页面时,我发现一团糟。
查看
<ion-item *ngFor="#option of productData">
<ion-label>{{option.val}}</ion-label>
<ion-radio (click)="goToProduct($event, option.catalogId)" [checked]="option.val == selected"></ion-radio>
</ion-item>
函数
goToProduct(event, catalogId) {
this.nav.push(ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
我认为我需要删除旧的产品页面,所以我在做:
goToProduct(event, catalogId) {
this.nav.remove(1);
this.nav.push(ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
像这样的各种变体,但没有任何效果。
我知道 Ionic 2 仍处于测试阶段,这是一个已知问题吗?或者我错过了什么?我怎样才能 select 一个选项并使更新的页面方向向后移动而不破坏我的应用程序?
如果我使用 insert()
而不是 push()
,它会根据需要返回到更新的产品,并完全删除旧的产品页面。阅读文档时我没想到会出现这种行为,但我想这是一个不错且简单的解决方案。
goToProduct(event, catalogId) {
this.nav.insert(1, ProductPage, {
catalogId: catalogId
},{
direction: 'back'
});
}
感谢楼上的回答,对我帮助很大
我需要应用我的应用程序页面的 转换 我已经完成了这个但是有一个问题 -
- 每当我回来时,它在某个时间点 重叠 某个页面。
- 经过一番搜索,我解决了这个问题。
这是我的代码-
goBack() {
{
this.nav.insert(0,MyPage, {
PId: this.parentId
},{direction: 'back'});
}
{
this.nav.pop();
}
}
我们也可以根据需要使用{direction: 'forward'}
。
我刚刚将 1 替换为 0 参数并为我工作。
祝你有愉快的一天!!!