doubleyong
管理员
管理员
  • 最后登录2025-02-06
  • 发帖数1196
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:744回复:0

【鸿蒙】Navigation组件引入的页面,底部显示空白,页面不完整

楼主#
更多 发布于:2024-10-09 13:01
在进行鸿蒙应用开发时,遇到下面的问题:


使用Navigation来显示引入的组件时,组件显示不完整,有部分是白色


代码如下:


import ChartIndex from './Chart/chartIndex'


import DetailIndex from './Detail/detailIndex'
import RecordIndex from './Record/recordIndex'
import { cloudFunction } from '@kit.CloudFoundationKit';
import { BusinessError } from '@kit.BasicServicesKit';
interface ToolBarItem{
  title:string,
  icon:Resource ,
  selIcon:Resource
}
@Entry
@Component
struct Index {
  @Builder NavigationToolBar(){
     Row(){
      ForEach(this.toolBarData,(v:ToolBarItem,i:number)=>{
        Column(){
          Image(this.selected==i?v.selIcon:v.icon).width(30)
          Text(v.title).fontColor(this.selected==i?$r('app.color.default_color'):
          $r('app.color.font_color')).fontSize($r('app.float.font_size1'))
        }.onClick(()=>{
          this.selected = i
        })
      })
     }.height(66).width('100%').justifyContent(FlexAlign.SpaceAround)
  }
  @State selected:number = 0
  @State toolBarData: ToolBarItem[] = [
    {title:'明细',icon:$r('app.media.zhufang'),selIcon:$r('app.media.zhangbensel')},
    {title:'记账',icon:$r('app.media.tianjia'),selIcon:$r('app.media.tianjiasel')},
    {title:'图标',icon:$r('app.media.tubiao'),selIcon:$r('app.media.tubiaosel')},
  ]


 
  build() {
    Navigation(){
      if(this.selected==0){
        DetailIndex()
      }else if(this.selected==1){
        RecordIndex()
      }else{
        ChartIndex()
      }
    }.toolbarConfiguration(this.NavigationToolBar()).hideTitleBar(false)
  }
}




解决方案:


将.hideTitleBar属性设置为true, 代码:.hideTitleBar(true)


hideTitleBar属性的含义:设置是否隐藏标题栏。
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号