离子标签不会转到下一页

Posted

技术标签:

【中文标题】离子标签不会转到下一页【英文标题】:Ionic tabs will not go to next page 【发布时间】:2019-06-28 20:56:24 【问题描述】:

我有一个 ionic 应用程序项目,底部有标签,我正在尝试创建一个新标签以链接到我创建的新页面,当我执行正确的代码时,它不会在按下后转到该页面新制作的标签按钮我联系了离子支持,他们说它看起来不错,但他们无法进一步帮助我

这是我的离子标签代码

import  NgModule  from '@angular/core';
import  RouterModule, Routes  from '@angular/router';
import  TabsPage  from './tabs.page';

import  FormsPage  from 'forms.page'

const routes: Routes = [
  
    path: 'tabs',
    component: TabsPage,
    children: [
      
        path: 'tab1',
        children: [
          
            path: '',
            loadChildren: '../tab1/tab1.module#Tab1PageModule'
          
        ]
      ,
      
        path: 'parties',
        children: [
          
            path: '',
            loadChildren: '../tab2/tab2.module#Tab2PageModule'
          
        ]
      ,
      
        path: 'tab3',
        children: [
          
            path: '',
            loadChildren: '../tab3/tab3.module#Tab3PageModule'
          
        ]
      ,
      
        path: '',
        redirectTo: '/tabs/tab1',
        pathMatch: 'full'
      
    ]
  ,
  
    path: 'forms',
    children: [
      
        path: '',
        loadChildren: '../forms/forms.module#FormsPageModule'
      
    ]

  ,
  
    path: '',
    redirectTo: '/tabs/tab1',
    pathMatch: 'full'
  
  
];

@NgModule(
  imports: [
    RouterModule.forChild(routes)
  ],
  exports: [RouterModule]
)
export class TabsPageRoutingModule 

<ion-tabs>

  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="tab1">
      <ion-icon name="flash"></ion-icon>
      <ion-label>Tab One</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="parties">
      <ion-icon name="apps"></ion-icon>
      <ion-label>Tab Two</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="tab3">
      <ion-icon name="send"></ion-icon>
      <ion-label>Tab Three</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="forms">
  <ion-icon name="clipboard"></ion-icon>
    <ion-label>Forms</ion-label>
</ion-tab-button>

</ion-tab-bar>

</ion-tabs>

【问题讨论】:

【参考方案1】:

试试这个配置。

  const routes: Routes = [
  
    path: 'tabs',
    component: TabsPage,
    children: [
      
        path: 'tab1',
        loadChildren: '../tab1/tab1.module#Tab1PageModule'
      ,
      
        path: 'parties',
        loadChildren: '../tab2/tab2.module#Tab2PageModule'
      ,
      
        path: 'tab3',
        loadChildren: '../tab3/tab3.module#Tab3PageModule'
      
    ]
  ,
  
    path: 'forms',
    children: [
      
        path: '',
        loadChildren: '../forms/forms.module#FormsPageModule'
      
    ]

  ,
  
    path: '',
    redirectTo: '/tabs/tab1'
  

];

并且在所有孩子中确保有这个路由:

  const routes: Routes = [
  
    path: '',
    component: Tab1Page
  
];

这适用于标签中的每个子页面。

【讨论】:

所以这必须在作为底部导航一部分的每个页面上? const 路线:路线 = [ 路径:'',组件:Tab1Page ]; 取决于页面的名称。所以改变 Tab1Page 取决于你是什么页面 我也这样做了,当我在服务中运行它时我得到无法获得/ 我已经完成了这段代码,但它不起作用我运行代码时出现错误

以上是关于离子标签不会转到下一页的主要内容,如果未能解决你的问题,请参考以下文章

确保在转到下一页之前发送了Google Analytics事件

chrome浏览器快捷键

layui中上一页,下一页,跳转到第几页,确定如何变为英文

layui中上一页,下一页,跳转到第几页,确定如何变为英文?

如何跳转到 PrintDocument 的下一页?

单击按钮时转到下一页并刷新上一个 Jquery Mobile