我试图理解另一个程序员的代码,并且有一个 initEvents () 方法。有些文章说这是一种过时的方法,但我不确定。你可以帮帮我吗?这是什么?它真的已经过时了吗?
小智 9
这确实是一个已弃用的方法init the event before dispatching,您应该使用具有第二个参数的事件构造函数来进行事件初始化,然后根据需要分派事件。
像这样的东西:
// create a look event that bubbles up and cannot be canceled
var evt = new Event("look", {"bubbles":true, "cancelable":false});
document.dispatchEvent(evt);
// event can be dispatched from any element, not only the document
myDiv.dispatchEvent(evt);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9675 次 |
| 最近记录: |