采用Tabs导航组件来配合布局,通过导航组件的barMode(BarMode.Scrollable)属性来设置导航栏滚动。示例代码@Entry @Component struct indexHi{ build(){ Column(){ Tabs({barPosition:BarPosition.End}) { //内容区域 TabContent() { //在内容区域继续提供顶部导航栏 Column(){ Tabs({barPosition:BarPosition.Start}){ //顶部导航栏内容 TabContent(){ Text('关注的内容').fontSize(30) }.tabBar('关注') .backgroundColor(Color.Black) TabContent(){ Text('视频的内容').fontSize(30) }.tabBar('视频') .backgroundColor(Color.Blue) TabContent(){ Text('游戏的内容').fontSize(30) }.tabBar('游戏') .backgroundColor(Color.Brown) TabContent(){ Text('数码的内容').fontSize(30) }.tabBar('数码') .backgroundColor(Color.Gray) TabContent(){ Text('科技的内容').fontSize(30) }.tabBar('科技') .backgroundColor(Color.Orange) TabContent(){ Text('体育的内容').fontSize(30) }.tabBar('体育') .backgroundColor(Color.Pink) TabContent(){ Text('影视的内容').fontSize(30) }.tabBar('影视') .backgroundColor(Color.Red) TabContent(){ Text('人文的内容').fontSize(30) }.tabBar('人文') .backgroundColor(Color.Yellow) } //设置导航栏(滚动) .barMode(BarMode.Scrollable) } .width('100%') } .tabBar('首页') TabContent() { Text('推荐的内容').fontSize(30) } .tabBar('推荐') TabContent() { Text('发现的内容').fontSize(30) } .tabBar('发现') TabContent() { Text('我的内容').fontSize(30) } .tabBar("我的") } //设置是否滚动切换,默认是滚动的,false禁止滚动切换 .scrollable(false) } } }参考链接tabs-滚动导航栏
采用Tabs导航组件来配合布局,通过导航组件的barMode(BarMode.Scrollable)属性来设置导航栏滚动。
示例代码
参考链接
tabs-滚动导航栏