我测试了,它可以工作,但我不确定这是否是我的浏览器。babel是否支持有第三个参数的addEventListener
作为对象?我想设置once:true
:
的目标。addEventListener(type, listener[, options]);
options Optional
An options object that specifies characteristics about the event listener. The available options are:
capture: A Boolean that indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.
once: A Boolean indicating that the listener should be invoked at most once after being added. If it is true, the listener would be removed automatically when it is invoked.
passive: A Boolean indicating that the listener will never call preventDefault(). If it does, the user agent should ignore it and generate a console warning.
Babel不提供这样的东西。Babel试图让标准的ES6+语法和库功能在旧的浏览器中工作。DOM API (addEventListener
是其中的一部分)不是由ECMAScript语言规范定义的,因此它与Babel无关。
你想加载一个DOM多边形,如https://github.com/WebReflection/dom4.