Home > DMT_Event > removeEventListener
DMT_Event.removeEventListener() method
移除事件监听
签名
typescript
function removeEventListener(id: string): boolean;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
id | string | 事件 ID |
返回值
boolean
是否移除指定事件监听
示例
javascript
const listenerId = '嘉立创示例_tab_remove';
// 1. 先注册一个监听作为移除目标
eda.dmt_Event.addEditorTabEventListener(
listenerId,
'toggle',
() => {}
);
const registered = eda.dmt_Event.isEventListenerAlreadyExist(listenerId);
console.log('registered:', registered);
// 2. 移除该监听
const removed = eda.dmt_Event.removeEventListener(listenerId);
console.log('removed:', removed);
// 3. 回读确认已不存在
const existAfter = eda.dmt_Event.isEventListenerAlreadyExist(listenerId);
console.log('existAfter:', existAfter);
// 4. 重复移除同一 id:返回 false(本就未注册)
const removedAgain = eda.dmt_Event.removeEventListener(listenerId);
console.log('removedAgain:', removedAgain);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22