我工作的有關Custom Events
任務,並想知道,是有event data
event.initEvent VS event.initCustomEvent
MDN - The old-fashioned way這些方法除了額外的參數之間的差異采用event.initEvent
但MDN - Cutom Events的填充工具使用event.initCustomEvent
來初始化事件。
我已經提到Passing additional arguments in custom Event,但我們甚至可以使用event.details
來設置event data
。
JSFiddle - Event data with initEvent
所以現在的問題是,有使用特定的其中一方的任何好處?
但它仍然存在,都在[W3C](https://www.w3。org/TR/dom /#dom-event-initevent)和[WHATWG](https://dom.spec.whatwg.org/#dom-event-initevent)規範。 – Oriol