harmony 鸿蒙Types

  • 2025-06-12
  • 浏览 (3)

Types

说明:

  • 本模块接口从API version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

  • 示例效果请以真机运行为准,当前IDE预览器不支持。

WebviewController9+

type WebviewController = WebviewController

提供Web控制器的方法。

系统能力: SystemCapability.Web.Webview.Core

类型 说明
WebviewController 通过WebviewController可以控制Web组件各种行为。一个WebviewController对象只能控制一个Web组件,且必须在Web组件和WebviewController绑定后,才能调用WebviewController上的方法(静态方法除外)。

OnAdsBlockedCallback12+

type OnAdsBlockedCallback = (details: AdsBlockedDetails) => void

当页面发生广告过滤时触发此回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
details AdsBlockedDetails 发生广告拦截时,广告资源信息。

OnSslErrorEventCallback12+

type OnSslErrorEventCallback = (sslErrorEvent: SslErrorEvent) => void

用户加载资源时发生SSL错误时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
sslErrorEvent SslErrorEvent 用户加载资源时发生SSL错误时触发的回调详情。

OnContextMenuHideCallback11+

type OnContextMenuHideCallback = () => void

上下文菜单自定义隐藏的回调。

系统能力: SystemCapability.Web.Webview.Core

OnRenderProcessNotRespondingCallback12+

type OnRenderProcessNotRespondingCallback = (data : RenderProcessNotRespondingData) => void

渲染进程无响应时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
data RenderProcessNotRespondingData 渲染进程无响应的详细信息。

OnRenderProcessRespondingCallback12+

type OnRenderProcessRespondingCallback = () => void

渲染进程由无响应状态变回正常运行状态时触发该回调。

系统能力: SystemCapability.Web.Webview.Core

OnViewportFitChangedCallback12+

type OnViewportFitChangedCallback = (viewportFit: ViewportFit) => void

网页meta中viewport-fit配置项更改时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
viewportFit ViewportFit 网页meta中viewport-fit配置的视口类型。

OnNativeEmbedVisibilityChangeCallback12+

type OnNativeEmbedVisibilityChangeCallback = (nativeEmbedVisibilityInfo: NativeEmbedVisibilityInfo) => void

当同层标签可见性变化时触发该回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
nativeEmbedVisibilityInfo NativeEmbedVisibilityInfo 提供同层标签的可见性信息。

OnFullScreenEnterCallback12+

type OnFullScreenEnterCallback = (event: FullScreenEnterEvent) => void

Web组件进入全屏时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
event FullScreenEnterEvent Web组件进入全屏的回调事件详情。

OnFirstMeaningfulPaintCallback12+

type OnFirstMeaningfulPaintCallback = (firstMeaningfulPaint: FirstMeaningfulPaint) => void

网页绘制页面度量信息的回调,当网页加载完页面主要内容时会触发该回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
firstMeaningfulPaint FirstMeaningfulPaint 绘制页面主要内容度量的详细信息。

OnLargestContentfulPaintCallback12+

type OnLargestContentfulPaintCallback = (largestContentfulPaint: LargestContentfulPaint) => void

网页绘制页面最大内容度量信息的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
largestContentfulPaint LargestContentfulPaint 网页绘制页面最大内容度量的详细信息。

OnNavigationEntryCommittedCallback11+

type OnNavigationEntryCommittedCallback = (loadCommittedDetails: LoadCommittedDetails) => void

导航条目提交时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
loadCommittedDetails LoadCommittedDetails 提供已提交跳转的网页的详细信息。

OnSafeBrowsingCheckResultCallback11+

type OnSafeBrowsingCheckResultCallback = (threatType: ThreatType) => void

网站安全风险检查触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
threatType ThreatType 定义网站threat类型。

OnIntelligentTrackingPreventionCallback12+

type OnIntelligentTrackingPreventionCallback = (details: IntelligentTrackingPreventionDetails) => void

当跟踪者cookie被拦截时触发的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
details IntelligentTrackingPreventionDetails 提供智能防跟踪拦截的详细信息。

OnOverrideUrlLoadingCallback12+

type OnOverrideUrlLoadingCallback = (webResourceRequest: WebResourceRequest) => boolean

onOverrideUrlLoading的回调。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
webResourceRequest WebResourceRequest url请求的相关信息。

返回值:

类型 说明
boolean 返回true表示阻止此次加载,否则允许此次加载。

WebKeyboardCallback12+

type WebKeyboardCallback = (keyboardCallbackInfo: WebKeyboardCallbackInfo) => WebKeyboardOptions

拦截网页可编辑元素拉起软键盘的回调,一般在点击网页input标签时触发。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
keyboardCallbackInfo WebKeyboardCallbackInfo 拦截网页拉起软键盘回调通知的入参,其中包括WebKeyboardController、可编辑元素的属性。

返回值:

类型 说明
WebKeyboardOptions 回调函数通过返回WebKeyboardOptions来决定ArkWeb内核拉起不同类型的软键盘。

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkWeb(方舟Web)

harmony 鸿蒙ArkWeb_AnyNativeAPI

harmony 鸿蒙ArkWeb_ComponentAPI

harmony 鸿蒙ArkWeb_ControllerAPI

harmony 鸿蒙ArkWeb_CookieManagerAPI

harmony 鸿蒙ArkWeb_JavaScriptBridgeData

harmony 鸿蒙ArkWeb_JavaScriptObject

harmony 鸿蒙ArkWeb_JavaScriptValueAPI

harmony 鸿蒙ArkWeb_ProxyMethod

harmony 鸿蒙ArkWeb_ProxyMethodWithResult

0  赞