HarmonyOS WebView加载url无法滚动?

如题:HarmonyOS WebView加载url无法滚动?

阅读 585
1 个回答

scroll 里面嵌套webView,demo参考:

// xxx.ets
import web_webview from '@ohos.web.webview'

@Entry
@Component
struct WebComponent {
  controller: web_webview.WebviewController = new web_webview.WebviewController()
  @State mode: WebLayoutMode = WebLayoutMode.FIT_CONTENT

  build() {
    Column() {
      Text("这里是头部区域")
        .width("100%")
        .height('30%')
        .backgroundColor("#f89f0f")
        .fontSize(28)
        .fontColor("#FF0F0F")
      Web({ src: $rawfile('Index.html'), controller: this.controller })
        .width('100%')
        .height(200)// .layoutMode(this.mode)
        .zoomAccess(false)
        .domStorageAccess(true)
        .overviewModeAccess(true)
        .imageAccess(true)
        .onlineImageAccess(true)
        .fileAccess(true)
        .databaseAccess(true)
      Text("这里是底部区域")
        .fontSize(28)
        .fontColor("#FF0F0F")
        .width("100%")
        .height('40%')
        .backgroundColor("#f89f0f")
    }
    .width('100%')
    .height('100%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进