自定义事件

var myEvent = new CustomEvent("userLogin", {
    detail: {
        username: "davidwalsh"
    }
});
 
// 触发它!
document.dispatchEvent(myEvent);<br>
document.addEventListener("userLogin", function(e) {
    console.info("Event is: ", e);
    console.info("Custom data is: ", e.detail);
})
上一篇:2021-04-27


下一篇:python爬虫案例