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

HarmonyOS
20h前
浏览
收藏 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);
  }
}
分享
微博
QQ
微信
回复
17h前
相关问题
HarmonyOS 底部导航条沉浸方案
338浏览 • 1回复 待解决
HarmonyOS 沉浸方案
270浏览 • 1回复 待解决
HarmonyOS 沉浸状态栏
143浏览 • 1回复 待解决
HarmonyOS 关于沉浸效果开发
66浏览 • 1回复 待解决
HarmonyOS List组件沉浸问题
37浏览 • 1回复 待解决