openharmony 鸿蒙 arkts-apis-webview-WebMessageExt

2026-08-25 浏览 (1)

Class (WebMessageExt)

Implements a WebMessageExt object that received and sent by the WebMessagePort API.

NOTE

  • The initial APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this class are supported since API version 10.

  • The sample effect is subject to the actual device.

getType10+

getType(): WebMessageType

Obtains the type of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
WebMessageTypeData types supported by the webMessagePort API.

getString10+

getString(): string

Obtains string-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringData of the string type.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

getNumber10+

getNumber(): number

Obtains number-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberData of the number type.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

getBoolean10+

getBoolean(): boolean

Obtains Boolean-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
booleanData of the Boolean type.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

getArrayBuffer10+

getArrayBuffer(): ArrayBuffer

Obtains raw binary data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ArrayBufferRaw binary data.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

getArray10+

getArray(): Array<string|number|boolean>

Obtains array-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
Array<string |number |boolean>Data of the array type.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

getError10+

getError(): Error

Obtains the error-object-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ErrorData of the error object type.

Error codes

For details about the error codes, see Webview Error Codes.

IDError Message
17100014The type and value of the message do not match.

setType10+

setType(type: WebMessageType): void

Sets the type for the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
typeWebMessageTypeYesData types supported by the webMessagePort API.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setString10+

setString(message: string): void

Sets the string-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messagestringYesString type.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setNumber10+

setNumber(message: number): void

Sets the number-type data of the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messagenumberYesData of the number type.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setBoolean10+

setBoolean(message: boolean): void

Sets the Boolean-type data for the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messagebooleanYesData of the Boolean type.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setArrayBuffer10+

setArrayBuffer(message: ArrayBuffer): void

Sets the raw binary data for the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messageArrayBufferYesRaw binary data.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setArray10+

setArray(message: Array<string|number|boolean>): void

Sets the array-type data for the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messageArray<string |number |boolean>YesData of the array type.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

setError10+

setError(message: Error): void

Sets the error-object-type data for the data object. For details about the sample code, see onMessageEventExt.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
messageErrorYesData of the error object type.

Error codes

For details about the error codes, see Webview Error Codes and Universal Error Codes.

IDError Message
17100014The type and value of the message do not match.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-webview-WebviewController

openharmony 鸿蒙 arkts-apis-webview-t

openharmony 鸿蒙 arkts-apis-webview

openharmony 鸿蒙 capi-arkweb-type-h

openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler

openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager

openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler

openharmony 鸿蒙 capi-web-arkweb-webmessage8h

openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/L9ARcOTc