可以给自定义navigationtitle用row包裹并给与.width(‘100%’).justifyContent(FlexAlign.Center)属性,参考代码如下:@Entry @Component struct Page { @State message: string = 'Hello World'; build() { Navigation(){ Row(){ Column(){ Text(this.message) .fontSize( 50) .fontWeight(FontWeight.Bold) }.width('100%') }.height('100%') }.title(this.navitionTitle) .titleMode(NavigationTitleMode.Mini) .hideBackButton(true) .menus(this.navigationMenus()) } @Builder navitionTitle(){ Row(){ Text("购买记录") .fontWeight(FontWeight.Bold) }.width('100%').justifyContent(FlexAlign.Center) } @Builder navigationMenus(){ Row(){ Image($r('app.media.app_icon')) .width(24) .height(24) .margin({right:14,top:10}) } } }
可以给自定义navigationtitle用row包裹并给与.width(‘100%’).justifyContent(FlexAlign.Center)属性,参考代码如下: