![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
nyqykk
这个作者很懒,什么都没留下…
展开
-
手写简版eventBus
class MyEventBus{ constructor() { this.events = {}; } on(eventName, callBack){ if(!this.events[eventName]){ this.events[eventName] = []; } this.events[eventName].push(callBack); } emit(eventName, ...args){ if(!this.eve原创 2021-02-09 18:37:56 · 137 阅读 · 0 评论 -
手写ajax
function ajax(options = {}){ return new Promise((resolve, reject) => { const { method, data, url } = options; const xhr = new XMLHttpRequest(); xhr.onreadystatechange = () => { if(xhr.readyState == 4){ xhr.s..原创 2021-02-09 16:39:30 · 133 阅读 · 0 评论