</scripttype="text/javascript"> window.addEventListener('DOMContentLoaded', () => { let count = document.getElementById('count'); let inc = document.getElementById('inc'); let dec = document.getElementById('dec');
let source = { count: 1 };
let render = value => { count.innerHTML = value; }
let options = { set: function (target, property, value) { target[property] = value; render(value); } };
/** 移除事件监听器 */ removeEvent(type, handler) { if (!(type inthis.handlers)) { returnnewError('还没有注册该事件'); } if (!handler) { deletethis.handlers[type]; return; } let idx = this.handlers[type].findIndex(ele == handler); this.handlers[type].splice(idx, 1); if (this.handlers[type].length <= 0) { deletethis.handlers[type]; } } }
let event = new Event(); let load = params => { console.log('load', params); } let load2 = params => { console.log('load2', params); } event.addEventListener('load', load); event.addEventListener('load', load2); event.dispatchEvent('load', 'params is this'); // load params is this 换行 load2 params is this