gpt4 book ai didi

javascript - 在哪里可以找到有关 polymer 中自定义事件对象的文档?

转载 作者:太空宇宙 更新时间:2023-11-04 15:56:17 25 4
gpt4 key购买 nike

我注意到一些自定义事件的演示显示了类似的内容

this.fire("myEvent", {message: "My custom event fired"});

然后监听器将调用一个函数来获取事件对象,例如

myFunction: function(e){
console.log(e.detail.message);
}

为什么我不能只发送电子邮件?细节从何而来?我创建了一个测试自定义事件并触发它,然后控制台记录了 e,我得到了以下对象

bubbles:true
cancelBubble:false
cancelable:false
composed:false
currentTarget:null
defaultPrevented:false
detail:Object
eventPhase:0
isTrusted:false
path:Array[7]
returnValue:true
srcElement:lala-element
target:lala-element
timeStamp:4848.3150000000005
type:"waiting"
__proto__:Event

那么所有这些都是从哪里来的,我在哪里可以读到相关内容?

最佳答案

How come I can't just do e.message? Where did the detail come from?

这是 DOM spec for CustomEvent 的一部分。我假设用户提供的 detail 封装在事件的 detail 字段中,以将用户的数据与事件自己的元数据完全分开。

So where did all of this come from, and where can I read about it?

CustomEvent 的 API 可以在 MDN 上找到。 .

关于javascript - 在哪里可以找到有关 polymer 中自定义事件对象的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42661881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com