界面分析:
由于整体UX设计图符合从上至下的布局,所以可以采用Column组件作为外层容器
简介:

实现标题、Banner、简介:
1. Column() { 2. Text('标题') 3. .fontFamily('HarmonyHeiTi-Bold') 4. .fontSize(24) 5. .fontColor(Color.Black) 6. .textAlign(TextAlign.Start) 7. .lineHeight(33) 8. .fontWeight(700) 9. .width('100%') 10. } 11. .padding({ top: 12, right: 16, bottom: 12, left: 16}) 12. .backgroundColor('#F1F3F5') 1. Image($r('app.media.yourpicture')) 2. .width('100%') 3. .borderRadius(16) 4. .margin({ top: 19, bottom: 8 }) 1. Text('简介') 2. .fontFamily('HarmonyHeiTi') 3. .fontSize(14) 4. .fontColor('rgba(0,0,0,0.60)') 5. .fontWeight(400) 6. .textAlign(TextAlign.Start) // @Component功能更加多样,有自己的生命周期,还能支持预览效果 // 而@Builder更加轻量,能满足基础的组件封装,性能更好,但是不支持预览 1. @Component 2. export struct Item { 3. build() { 4. Row(){ 6. } 7. .width('100%') 8. .height(48) 9. .borderRadius(16) 10. .alignItems(VerticalAlign.Center) 11. .padding({ left: 12, right: 12 }) 12. .backgroundColor('#F1F3F5') 13. } 14. } 1. export struct Item { 2. @State navBarItem: NavBarItemType = { 3. order: '01', 4. title: '标题' 5. }; 6. ... 7. } 1. @Component 2. export struct Item { 3. ... 5. build() { 6. Row() { 7. Text(this.navBarItem.order) 8. .margin({ right: 6 }) 9. .fontFamily('HarmonyHeiTi-Bold') 10. .fontSize(21) 11. .fontColor('#182431') 12. .textAlign(TextAlign.Start) 13. .lineHeight(22) 14. .fontWeight(700) 15. } 16. ... 17. } 18. } 1. @Component 2. export struct Item { 3. ... 5. build() { 6. Row() { 7. Text(this.navBarItem.order) 8. ... 9. Text(this.navBarItem.title) 10. .fontFamily('HarmonyHeiTi-Medium') 11. .fontSize(16) 12. .fontColor('#182431') 13. .textAlign(TextAlign.Start) 14. .lineHeight(22) 15. .fontWeight(500) 16. } 18. } 19. } 1. @Component 2. export struct Item { 3. ... 5. build() { 6. Row() { 7. Text(this.navBarItem.order) 8. ... 9. Text(this.navBarItem.title) 10. ... 11. Blank() 12. Image($r('app.media.ic_arrow')) 13. .width(12) 14. .height(24) 15. } 16. ... 17. } 18. } 组合列表项:
1. @State navBarList: NavBarItemType[] = [ 2. { order: '01', title: '准备与学习' }, 3. { order: '02', title: '构建应用' }, 4. { order: '03', title: '应用测试' }, 5. { order: '04', title: '上架' }, 6. { order: '05', title: '运营增长' }, 7. { order: '06', title: '商业变现' }, 8. { order: '07', title: '更多' } 9. ]; 1. List({ space: 12 }) { 2. ForEach(this.navBarList, (item: NavBarItemType, index: number) => { 3. ListItem() { 4. NavBarItem({ navBarItem: item }) 5. } 6. .width('100%') 7. }, (item: NavBarItemType): string => item.title) 8. } 9. .width('100%') 10. .margin({ top: 24 })