javascript - 登录后单击硬件后退按钮导航到登录页面如何在离子4中防止它
问题描述
const routes: Routes = [
{
path: '',
component: TabsPage,
children: [
//new page add
{
path: 'home',
children: [
{
path: '', loadChildren: () => import('../AllPages/home/home.module').then(m => m.HomePageModule)
},
{
path: 'new-arrival',
children: [
{
path: '',
loadChildren: () => import('../AllPages/new-arrival/new-arrival.module').then(m => m.NewArrivalPageModule)
},
{
path: 'product-item-list',
children: [
{
path: '',
loadChildren: () => import('../Allpages/product-item-list/product-item-list.module').then(m => m.ProductItemListPageModule)
},
{
path: 'product-details',
children: [
{
path: '',
loadChildren: () => import('../Allpages/product-details/product-details.module').then(m => m.ProductDetailsPageModule)
},
]
}
]
}
]
},
解决方案
使用 Ionic NavController 而不是 Angular Router。
然后,使用navigateRoot
方法。
去根意味着堆栈中的所有现有页面都将被删除,导航页面将成为堆栈中的单个页面。
import { NavController } from '@ionic/angular';
...
constructor(private navController: NavController) {}
...
this.navController.navigateRoot('/tabs/home');
推荐阅读
- python - Avoid repetition of loop body before loop
- unit-testing - 模拟在方法内创建的对象
- html - 我可以在同一页面的不同面板中打开多个地图/网址吗?
- python - 从 pd.get_dummies 将预测转换为分类
- python - Django模板错误:无法解析剩余部分
- hadoop - 如何使用 apache Pig 插入过滤数据的索引?
- php - 如何使用 php 将用户输入放入文本文件?
- javascript - 有条件地从 React-Native FlatList 渲染一些项目
- r - 线宽方向重叠ggplot
- java - 如何在 Java 的 HashSet 中仅打印唯一的非重复值?