ionic4 入门 (三) 完善tabs

ionic4 入门 (三) 完善tabs

创建 界面

  1. cli : ionic g page cart/cart 创建 cart 路径下的 home 界面

  2. cli : ionic g page mine/mine 创建 mine 路径下的 mine 界面

配置路由

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';

import { IonicModule } from '@ionic/angular';

import { TablsPage } from './tabls.page';
import { LoginGuardGuard } from 'src/guard/login-guard.guard';

const routes: Routes = [
  {
    path: '',
    component: TablsPage,
    children: [
      {
        path: '',
        // loadChildren: '../home/home/home.module#HomePageModule',
        redirectTo: 'home',
        pathMatch: 'full'
      },
      {
        path: 'home',
        children: [
          {
            path: '',
            loadChildren: '../home/home/home.module#HomePageModule'
          }
        ]
      },
      {
        path: 'classify',
        children: [
          {
            path: '',
            loadChildren: '../classify/classify/classify.module#ClassifyPageModule'
          }
        ]
      },
      {
        path: 'cart',
        children: [
          {
            path: '',
            loadChildren: '../cart/cart/cart.module#CartPageModule',
            canActivate: [LoginGuardGuard]
          }
        ]
      },
      {
        path: 'mine',
        children: [
          {
            path: '',
            loadChildren: '../mine/mine/mine.module#MinePageModule',
            canActivate: [LoginGuardGuard]
          }
        ]
      }
    ],
  },
  {
    path: '',
    redirectTo: 'tabls/home',
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [TablsPage]
})
export class TablsPageModule {}

html 页面配置


  
    
      
      首页
    

    
      
      分类
    

    
      
      购物车
    

    
      
      我的
    
    
  

项目地址

Git clone https://github.com/weixiaocheng/ioincApp.git

你可能感兴趣的:(ionic4 入门 (三) 完善tabs)