I was wondering, what is the purpose of CustomEvent
, because it can be easily emulated by good old Event
.
So, what is the difference between:
var e = new Event("reload");
e.detail = {
username: "name"
};
element.dispatchEvent(e);
and
var e = new CustomEvent("reload", {
detail: {
username: "name"
}
});
inner.dispatchEvent(e);
Why does CustomEvent
exist if it is easy to attach custom data to ordinary Event object?
question from:
https://stackoverflow.com/questions/40794580/event-vs-customevent 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…