> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# lynx: getJSModule() static method

APISummary
获取一个可以在当前 LynxView 中共享使用的 JavaScript 对象。

## 语法

```ts
getJSModule: <Module>(name: string) => Module;
```

### 参数

#### name

需要获取的对象名，该对象需要通过 [`lynx.registerModule`] 注册。

### 返回值

注册的对象。

如果 `name` 未被注册，返回 `undefined`。

## 示例

### 在 JS 中获取共享对象

获取一个通过 [`lynx.registerModule`] 注册的对象：

```js
const fooModule = {};
lynx.registerModule('foo', fooModule);
lynx.getJSModule('foo') === fooModule; // true
```

[`lynx.registerModule`]: /next/zh/api/lynx-api/lynx/lynx-register-module.md

## 兼容性

**Compatibility Table**

**Query:** `lynx-api.lynx.getJSModule`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/lynx/getJSModule.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| getJSModule | Yes (2.4) | Yes (3.4) | Yes (2.4) | Yes (3.5) | Yes (3.5) | Yes |

**`getJSModule`**

**Specifications:**

