使用说明
默认监听 at-target 与 bubble 阶段,因此后代事件可以冒泡到组件根。pointerenter / pointerleave 不冒泡;需要监听稳定内部节点时使用 ctx.onNode(),按动态节点名匹配时使用 ctx.delegate()。
返回值是显式取消函数;即使不手动调用,Runtime 也会在脚本释放时清理监听。
Runtime API / Method
在当前脚本根上监听统一事件,并参与 Runtime 的 capture、target、bubble 传播。
使用说明
默认监听 at-target 与 bubble 阶段,因此后代事件可以冒泡到组件根。pointerenter / pointerleave 不冒泡;需要监听稳定内部节点时使用 ctx.onNode(),按动态节点名匹配时使用 ctx.delegate()。
返回值是显式取消函数;即使不手动调用,Runtime 也会在脚本释放时清理监听。
参数
event | K |
|---|---|
handler | { ... } |
options | EventListenerOptions |