HarmonyOS 沉浸式页面底部会空余出一块高度

HarmonyOS
2024-12-26 14:58:49
1158浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

参考:

// Index.ets
import { WebComponent } from './WebPage'

import router from '@ohos.router'
import common from '@ohos.app.ability.common'

@Entry
@Component
struct NavigationExample {
  @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack();
  private context = getContext(this) as common.UIAbilityContext;
  @Builder
  PageMap(name: string) {
    if (name === 'pageOne') {
      //WebComponent({jsBridgeService:this.jsBridgeService});
    }
    else if (name === 'pageThree') {
      WebComponent();
    }
  }

  build() {
    Column(){
      Navigation(this.pageInfos) {
        Column() {
          Button('pushPath', { stateEffect: true, type: ButtonType.Capsule })
            .width('80%')
            .height(40)
            .margin(20)
            .onClick(() => {
              this.pageInfos.pushPath({ name: 'pageThree' }) //将name指定的NavDestination页面信息入栈
            })
        }
      }.title('NavIndex').navDestination(this.PageMap)
    }
  }
}
// WebPage.ets
import web_webview from '@ohos.web.webview';
@Component
export struct WebComponent {
  @Consume('pageInfos') pageInfos: NavPathStack;
  controller: web_webview.WebviewController = new web_webview.WebviewController();


  aboutToAppear() {
    // 配置Web开启调试模式
    web_webview.WebviewController.setWebDebuggingAccess(true);
  }

  build() {
    NavDestination() {
      Stack(){
        Text()
          .height('100%')
          .onClick((event)=>{
            let keyboardShow = AppStorage.get<boolean>('showKeyboard')
            if (keyboardShow) {
              //this.controller?.keyboardController.handleSM(false)
              AppStorage.setOrCreate('showKeyboard', false);
            }
          })
        // .backgroundColor(Color.Brown)
      }
      .backgroundColor(Color.Blue)
      .width('100%')
      .height('100%')
      .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
    }.title('pageOne')
    .onBackPressed(() => {
      this.pageInfos.pop() // 弹出路由栈栈顶元素
      console.log('pop' + '返回值' + JSON.stringify(this.pageInfos.pop()))
      return true
    }).hideTitleBar(true);
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
分享
微博
QQ
微信
回复
2024-12-26 18:21:01
相关问题
HarmonyOS 底部导航条沉浸方案
972浏览 • 1回复 待解决
HarmonyOS 沉浸方案
1117浏览 • 1回复 待解决
HarmonyOS 关于沉浸效果开发
969浏览 • 1回复 待解决
HarmonyOS List组件沉浸问题
741浏览 • 1回复 待解决
HarmonyOS 沉浸的适配文档
657浏览 • 1回复 待解决