美文网首页ArkTS/ArkUI实战
鸿蒙ArkTS/ArkUI电商实战-主框架导航

鸿蒙ArkTS/ArkUI电商实战-主框架导航

作者: ISwiftUI | 来源:发表于2022-06-11 00:59 被阅读0次

    鸿蒙ArkTS/ArkUI电商实战系列

    本章内容

    Tabs导航主框架

    效果图:


    效果图

    示例:
    MainPage.ets

    // 导入页面路由模块
    import Constants from '../common/constants/Constants';
    import { BottomTabsList } from '../viewmodel/BottomTabsModel';
    import HomePage from './HomePage';
    import MinePage from './MinePage';
    import MsgPage from './MsgPage';
    import ProjectPage from './ProjectPage';
    
    @Preview
    @Entry
    @Component
    struct MainPage {
      @State bottomTabIndex: number = 0;
      private tabsController: TabsController = new TabsController();
    
      build() {
        Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) {
          Tabs({ barPosition: BarPosition.End, index: 0, controller: this.tabsController }) {
            TabContent() {
              HomePage()
            }.tabBar(this.TabBuilder(0, 'Home'))
    
            TabContent() {
              ProjectPage()
            }.tabBar(this.TabBuilder(1, 'Project'))
    
            TabContent() {
              MsgPage()
            }.tabBar(this.TabBuilder(2, 'Msg'))
    
            TabContent() {
              MinePage()
            }.tabBar(this.TabBuilder(3, 'Me'))
    
          }
          .width(Constants.FULL_PERCENT)
          .height(Constants.FULL_PERCENT)
          .vertical(false)
          .scrollable(false)
          .barMode(BarMode.Fixed)
          .barHeight(Constants.BAR_HEIGHT)
          .onChange((index: number) => {
            this.bottomTabIndex = index;
          })
        }
        .width(Constants.FULL_PERCENT)
      }
    
      onIndexChange() {
        this.tabsController.changeIndex(this.bottomTabIndex);
      }
    
    }
    

    相关的源码

    相关文章

      网友评论

        本文标题:鸿蒙ArkTS/ArkUI电商实战-主框架导航

        本文链接:https://www.haomeiwen.com/subject/wpfgmrtx.html