HarmonyOS应用开发ArkUI(TS)电商项目实战

项目介绍

本项目基于 HarmonyOS 的ArkUI框架TS扩展的声明式开发范式,关于语法和概念直接看官网官方文档地址:基于TS扩展的声明式开发范式

工具版本: DevEco Studio 3.1 Canary1

SDK版本: 3.1.9.7(API Version 8 Release)

效果演示

页面解析

主框架

使用容器组件:Tabs 、TabContent、作为主框架,底部Tab使用自定义布局样式,设置点击事件,每次点击更换选中的索引。来切换内容页面。

使用自定义组件来实现:首页、分类、购物车、我的的搭建。

@Entry
@Component
struct MainFrame {
   
   
  @State selectIndex: number = 0
  private controller: TabsController = new TabsController()
  private tabBar = getTabBarList()

  // 内容
  @Builder Content() {
   
   
    Tabs({
    
     controller: this.controller }) {
   
   
      TabContent() {
   
   HomeComponent()}
      TabContent() {
   
   ClassifyComponent()}
      TabContent() {
   
   ShoppingCartComponent({
   
    isShowLeft: false })}
      TabContent() {
   
   MyComponent()}
    }
    .width('100%')
    .height(0)
    .animationDuration(0)
    .layoutWeight(1)
    .scrollable(false)
    .barWidth(0)
    .barHeight(0)
  }

  // 底部导航
  @Builder TabBar() {
   
   
    Row() {
   
   
      ForEach(this.tabBar, (item: TabBarModel, index) => {
   
   
        Column() {
   
   
          Image(this.selectIndex === index ? item.iconSelected : item.icon)
            .width(23).height(23).margin({
   
    right: index === 2 ? 3 : 0 })
          Text(item.name)
            .fontColor(this.selectIndex === index ? '#dc1c22' : '#000000')
            .margin({
   
    left: 1, top: 2 })
        }.layoutWeight(1)
        .onClick(() => {
   
   
          this.selectIndex = index
          this.controller.changeIndex(index)
        })
      }, item => item.name
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值