@FunC
2017-08-03T09:39:32.000000Z
字数 329
阅读 2082
javascript
想知道浏览器是否支持
addEventListener('event', callback, {passive:true});
通过getter来测试!
let passiveSupport = false;
const opts = Object.defineProperty({}, 'passive', {
get() {
passiveSupport = true;
}
});
//make it work
window.addEventListener('test', null, opts);
const passiveOpts = passiveSupport ? opts : false;