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, and this page is available as Markdown at /next/zh/api/lynx-api/lynx/lynx-get-js-module.md.
Lynx
  • 简体中文
  • lynx: getJSModule() static method

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

    语法

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

    参数

    name

    需要获取的对象名,该对象需要通过 lynx.registerModule 注册。

    返回值

    注册的对象。

    如果 name 未被注册,返回 undefined

    示例

    在 JS 中获取共享对象

    获取一个通过 lynx.registerModule 注册的对象:

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

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。