CustomEvent.detail
接口 CustomEvent
的只读属性 detail
(详情)返回在初始化事件对象时传递过来的任何类型数据。
备注: 此特性在 Web Worker 中可用
Syntax
let myDetail = customEventInstance.detail;
Return value
事件对象初始化时传递的任何类型数据。
Example
js
// add an appropriate event listener
obj.addEventListener("cat", function (e) {
process(e.detail);
});
// create and dispatch the event
let event = new CustomEvent("cat", {
detail: {
hazcheeseburger: true,
},
});
obj.dispatchEvent(event);
// Will return an object contaning the hazcheeseburger property
let myDetail = event.detail;
Specifications
Specification |
---|
DOM Standard # ref-for-dom-customevent-detail② |
Browser compatibility
BCD tables only load in the browser