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 页面配置

<ion-tabs>
  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="home">
      <ion-icon name = "home"></ion-icon>
      <ion-label>首页</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="classify">
      <ion-icon name="apps"></ion-icon>
      <ion-label>分类</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="cart">
      <ion-icon name="cart"></ion-icon>
      <ion-label>购物车</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="mine">
      <ion-icon name="person"></ion-icon>
      <ion-label>我的</ion-label>
    </ion-tab-button>
    
  </ion-tab-bar>
</ion-tabs>

项目地址

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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 可参考链接(仅参考): ionic官方文档链接:http://ionicframework.com/docs/ i...
    洗耳恭听_kai阅读 25,773评论 0 5
  • 作为一个后台开发人员,几年前参与过Ionic1开发过一微信公众号的经历,所以这次开发企业微信应用,就使用了i...
    shansheng阅读 1,073评论 0 5
  • 第1章 Shell和vi 1.1什么是shell 在计算机科学中,Shell俗称壳,用来区别于Kernel(核),...
    福尔摩鸡阅读 1,226评论 0 1
  • 目录 说明 环境搭建 起始一个ionic项目 angular(操作数据)在项目中常用到的点,以及与jq(操作dom...
    新林吃遍世界阅读 1,505评论 0 0
  • 这个冬季感觉就2字,累和冷。3个多月,基本没有睡好觉,舟车劳顿,深圳,曼谷,普吉岛,清迈,拜县,清莱,曼谷,深圳,...
    biu4beng3阅读 239评论 1 1

友情链接更多精彩内容