EventTarget 与 Event API
EventTarget
和 Event
对象是一些 Node.js 核心 API 暴露的 EventTarget
Web API 的特定于 Node.js 的实现。
const target = new EventTarget();
target.addEventListener('foo', (event) => {
console.log('foo event happened!');
});
The EventTarget
and Event
objects are a Node.js-specific implementation
of the EventTarget
Web API that are exposed by some Node.js core APIs.
const target = new EventTarget();
target.addEventListener('foo', (event) => {
console.log('foo event happened!');
});