首页 > 解决方案 > querySelectorAll/forEach 在 IE11 中不起作用

问题描述

尝试制作一些易于使用的卡片,但在 IE11 上遇到问题(不足为奇)。很确定我错过了一些明显的东西?我知道这是 js 的问题,但大脑无法正常工作:/

const cards = document.querySelectorAll('.card');  
Array.prototype.forEach.call(cards, card => {  
    let down, up, link = card.querySelector('h4 a');            
    card.style.cursor = 'pointer';
    card.onmousedown = () => down = +new Date();
    card.onmouseup = () => {
        up = +new Date();
        if ((up - down) < 200) {
            link.click();
        }
    }
});

标签: javascript

解决方案


尝试使用基本功能

Internet Explorer 不支持 es6 语法(箭头函数)

查看此链接以获取更多信息

IE数组函数栈溢出讨论

github讨论


推荐阅读