离子4功能在选项卡路由器上执行两次

时间:2019-06-17 02:47:16

标签: angular ionic-framework ionic4

我正在尝试使用制表符,但是制表符的功能在第一次加载(init)时会对其调用两次。

tab1页面中的函数加载两次-ionic-v4。 调用navigationByUrl之后,ngOnInit上的函数将加载两次 我登录后。

this.router.navigateByUrl(’/ tabs / tab1’); 这是我的tabs-router.module 下面的代码:

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

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'tab1',
        children: [
          {
            path: '',
            loadChildren: '../tab1/tab1.module#Tab1PageModule'
          }
        ]
      },
      {
        path: 'tab2',
        children: [
          {
            path: '',
            loadChildren: '../tab2/tab2.module#Tab2PageModule'
          }
        ]
      },
      {
        path: 'tab3',
        children: [
          {
            path: '',
            loadChildren: '../tab3/tab3.module#Tab3PageModule'
          }
        ]
      }
      // {
      //   path: '',
      //   redirectTo: '/tabs/tab1',
      //   pathMatch: 'full'
      // }
    ]
  },
  {
    path: 'responders',
    component: TabsPage,
    children: [
      {
        path: 'feed',
        children: [
          {
            path: '',
            loadChildren: '../feed/feed.module#FeedPageModule'
          }
        ]
      },
      {
        path: 'reported',
        children: [
          {
            path: '',
            loadChildren: '../reported/reported.module#ReportedPageModule'
          }
        ]
      },
      {
        path: 'reports',
        children: [
          {
            path: '',
            loadChildren: '../reports/reports/reports.module#ReportsPageModule'
          }
        ]
      },
      {
        path: 'waitingforapproval',
        children: [
          {
            path: '',
            loadChildren: '../modals/responderswaitinglist/responderswaitinglist.module#ResponderswaitinglistPageModule'
          }
        ]
      }
    ]
  },
  {
    path: '',
    redirectTo: '/login',
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [
    RouterModule.forChild(routes)
  ],
  exports: [RouterModule]
})

export class TabsPageRoutingModule { }

0 个答案:

没有答案