ソースを参照

导航栏返回按钮显隐

徐勤民 6 ヶ月 前
コミット
bdaee2fe47
1 ファイル変更7 行追加3 行削除
  1. 7 3
      src/main/ets/view/SafeView.ets

+ 7 - 3
src/main/ets/view/SafeView.ets

@@ -22,7 +22,11 @@ export struct SafeView {
   // 设置导航栏背景不透明度
   // 元素的不透明度,取值范围为0到1,1表示不透明,0表示完全透明, 达到隐藏组件效果,但是在布局中占位。
   @Prop opacitys: number | Resource
-  // 设置返回按钮事件
+  // 是否显示返回按钮
+  @Prop hideBack: boolean
+  @Prop showBadgeLeft: boolean;
+  @Prop showBadgeRight: boolean;
+  // 设置返回按钮事件,如果hideBack为true,该事件无效
   onBackEvent?: () => void = undefined
   // 设置返回按钮事件
   onClickLeft?: TitleBarBtn
@@ -60,12 +64,12 @@ export struct SafeView {
               .height(15)
               .objectFit(ImageFit.Contain)
               .onClick(() => {
-                if (this.onBackEvent) {
+                if (this.onBackEvent && !this.hideBack) {
                   this.onBackEvent()
                 } else if (this.pageInfos) {
                   this.pageInfos.pop()
                 }
-              })
+              }).visibility(!this.hideBack ? Visibility.Visible : Visibility.None)
           }.width(110)
 
           Text(`${this.titleText}`)