设置字体颜色,可以使用自定义导航栏参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-navigation-tabs-V5\#自定义导航栏demo:@Entry @Component struct TabsExample1 { @State currentIndex: number = 2 @Builder tabBuilder(title: string, targetIndex: number) { Column() { Text(title) .fontColor(this.currentIndex === targetIndex ? '#FF0000' : '#00FF00') } } build() { Column() { Tabs({ barPosition: BarPosition.End }) { TabContent() { }.tabBar(this.tabBuilder('首页', 0)) TabContent() { }.tabBar(this.tabBuilder('发现', 1)) TabContent() { }.tabBar(this.tabBuilder('推荐', 2)) TabContent() { }.tabBar(this.tabBuilder('我的', 3)) } .animationDuration(0) .backgroundColor('#F1F3F5') .onChange((index: number) => { this.currentIndex = index }) }.width('100%') } }
设置字体颜色,可以使用自定义导航栏参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-navigation-tabs-V5\#自定义导航栏
demo: