如何写精华回答,获更多曝光?
发布
@Entry
@Component
struct MainPage {
@State currentIndex: number = 0
@State Build: Array<Object> = [
{
text: '首页',
num: 0,
imageYes: $r('app.media.home_yes'),
imageNo: $r('app.media.home_no')
},
{
text: '视频',
num: 1,
imageYes: $r('app.media.home_yes'),
imageNo: $r('app.media.video_home_icn')
},
{
text: '商城',
num: 2,
imageYes: $r('app.media.shop_yes'),
imageNo: $r('app.media.shop_no')
},
{
text: '我的',
num: 3,
imageYes: $r('app.media.user_yes'),
imageNo: $r('app.media.user_no')
},
]
@Builder
NavigationTitle() {
Column() {
Text('Title')
.fontColor('#182431')
.fontSize(30)
.lineHeight(41)
.fontWeight(700)
Text('subtitle')
.fontColor('#182431')
.fontSize(14)
.lineHeight(19)
.opacity(0.4)
.margin({ top: 2, bottom: 20 })
}.alignItems(HorizontalAlign.Start)
}
@Builder
NavigationMenus() {
Row() {
Image($r('app.media.home_no'))
.width(24)
.height(24)
Image($r('app.media.video_home_icn'))
.width(24)
.height(24)
.margin({ left: 24 })
Image($r('app.media.shop_no'))
.width(24)
.height(24)
.margin({ left: 24 })
Image($r('app.media.user_no'))
.width(24)
.height(24)
.margin({ left: 24 })
}
}
@Builder
NavigationToolbar() {
Row() {
ForEach(this.Build, item => {
Column() {
Image(this.currentIndex == item.num ? item.imageYes : item.imageNo)
.width(24)
.height(24)
Text(item.text)
.fontColor(this.currentIndex == item.num ? '#007DFF' : '#182431')
.fontSize(10)
.lineHeight(14)
.fontWeight(500)
.margin({ top: 3 })
}.width(104).height(56)
.onClick(() => {
this.currentIndex = item.num
})
})
}.margin({ left: 24 })
}
build() {
Column() {
Navigation() {
}
.titleMode(NavigationTitleMode.Full)
.toolBar(this.NavigationToolbar)
.hideToolBar(false)
.onTitleModeChange((titleModel: NavigationTitleMode) => {
console.info('titleMode' + titleModel)
})
}.width('100%').height('100%').backgroundColor('#F1F3F5')
}
}