CustomEventEmitter
通过 CustomEventAccess 选定单个自定义事件后得到的句柄。事件的 emit 函数会让原生句柄保持有效,垃圾回收后仍可使用保存的事件发射器及 emit 函数。触发事件时,运行时会重新查找事件定义,定义不可用时会抛出 ReferenceError。
js
const threshold = this.event.ThresholdExceeded;
threshold.emit(this.property.temperature);
const emitThreshold = threshold.emit;
emitThreshold(this.property.temperature);方法
emit(...args)
触发选定的自定义事件。访问 this.event.EventName 时就已选定事件名称,因此调用 emit 时直接传入事件参数。
| 名称 | 类型 | 描述 |
|---|---|---|
args | * | 按定义顺序传入的事件参数值。 |
返回值: undefined
js
this.event.ThresholdExceeded.emit(this.property.temperature);