---
name: "WebviewContext.postMessage"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "WebviewContext.postMessage - 向 web-view 组件发送消息"
---

## WebviewContext.postMessage

> [VERSION] Base Library >= 2.21.8

### Description

Send a message to the web-view component

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `options` | `WebviewPostMessageOption` | Yes | Message options |

### Return Value

None


### Referenced Types

##### `interface` WebviewPostMessageOption

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `Record<string, unknown>` | Yes | Message data to send |


### Examples

#### Send a message to the web-view

```ts
const webviewCtx = ty.createWebviewContext('myWebview');
webviewCtx.postMessage({
  data: { type: 'update', value: 100 },
});
```
