Open powerdong opened 4 years ago
// 将hdList let list = Array.form(hdList)
//hdList转化为数组并用list变量接收 let list = Array.prototype.slice.call(hdList); //添加点击事件 list.forEach((current,index) => { current.addEventListener('click',() => { animationFn(index); },false); });
let list = [...hdList];//用[ ...elems ]方法转化为数组并用list接收
//直接对hdList集合进行循环或者map等 Array.prototype.forEach.call(hdList,function(){ //... }) Array.prototype.map.call(hdList,function(){ //... })
//添加点击事件 Array.prototype.forEach.apply(hdList,[(current,index) => { current.addEventListener('click',() => { animationFn(index); },false); }]);
//添加点击事件 Array.prototype.forEach.bind(hdList)((current,index) => { current.addEventListener('click',() => { animationFn(index); },false); });