mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-19 05:51:35 +08:00
1.1 KiB
Executable File
1.1 KiB
Executable File
Web 事件
当浏览器加载结束或者使用了一些三方库完成一些功能后需要向业务侧抛出事件。
事件发送
WebRenderer 在需要发送事件的地方调用以下代码:
在模块中
发送事件,HippyWebModule 基类提供的 context 提供了向业务层发送事件的能力
const eventName = '自定义名字';
const param = {};
context.sendEvent(eventName, param);
在 component 中
发送事件,HippyWebView 基类的 context 提供了向业务层发送事件的能力
const eventName = '自定义名字';
const param = {};
context.sendEvent(eventName, param);
在全局中
发送事件,Hippy.web.engine 的 context 提供了向业务层发送事件的能力
const engine = Hippy.web.engine;
const eventName = '自定义名字';
const param = {};
engine.context.sendEvent(eventName, param);