HarmonyOS 跳转的H5页面高度被截断,无法滚动?

如题:HarmonyOS 跳转的H5页面高度被截断,无法滚动?

阅读 586
1 个回答

下面的Demo h5页面能滚动,以供参考:

import { webview } from '@kit.ArkWeb';
@Entry
@Component
export struct HomeWebPage {
  controller: webview.WebviewController = new webview.WebviewController();
  @State url: string = ''
  @State isLoaded: boolean = false
  @Prop title: string = ''
  @State token: string = ''
  build() {
    Navigation() {

      // Text('头部')
      Web({ src: $rawfile("index.html"), controller: this.controller })
        .onControllerAttached(() => {
          this.isLoaded = true
          console.log('----: ',this.controller.getTitle())
        })
        .width('100%')
        .height('100%')
        .backgroundColor(Color.Red)
        .javaScriptAccess(true)
        .domStorageAccess(true)
        .mixedMode(MixedMode.All)
        .onTitleReceive((data) => {
        })
        .onErrorReceive((error) => {
          console.log('---:'+error)
        })
        .onHttpErrorReceive((error) => {
          console.log('---:'+error)
        })
        .onPageEnd(() => {
        })
    }
    .hideTitleBar(true)
    .height('100%')
  }
}
<!DOCTYPE html>
  <html>
  <meta charset="utf-8">
  <style>
  html{
  height:3000px
}
</style>
  <body>
  <p id="demo" style="height: 800px;background-color:yellow;">
  "文本内容"
  </p>
  </body>
  <script type="text/javascript">
  </script>
  </html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进