我在IE11上遇到问题,这行jquery无法识别.....:
const applyHeights = (items, height) => {
你知道如何让它发挥作用吗?太棒了!它在其他浏览器上工作正常,如chrome,safari,firefox等!
谢谢!
- 编辑 -
如下所示:
let maxHeight = Math.max(...heights);
- 所有代码 -
setTimeout(function (){
setTimeout(function() {
const applyHeights = function(items, height) {
const applyHeights = function(items, height) {
const applyHeights = function(items, height) {
items.forEach(function(item) {
let back = item.querySelector('.back'),
front = item.querySelector('.front');
back.style.height = height;
front.style.height = height;
item.style.height = height;
});
}
const getHeights =function (items, className) {
return Array.from(items).map(function(item) {
return item.querySelector('.${className}').offsetHeight;
});
}
const initFlip = function(id) {
let element = document.getElementById(id);
if(!element) return;
initHeights(element);
window.onresize = function(event) {
resetHeights(element);
initHeights(element);
}
}
const initHeights = function(element) {
let items = element.querySelectorAll('article'),
backHeights = getHeights(items, 'back'),
frontHeights = getHeights(items, 'front');
let heights = backHeights.concat(frontHeights);
var maxHeight = Math.max(...heights);
applyHeights(items, '${maxHeight}px');
}
const resetHeights = function(element) {
let items = element.querySelectorAll('article');
applyHeights(items, 'auto');
}
答案 0 :(得分:0)
x_lim
语法称为'箭头功能'。这是脚本语言规范ecmascript2015(ES6)的一个特性。
Internet Explorer 11在ES6中不支持本机。
为了在IE11上运行ES6,你需要一个可以编译es6到es5的编译器(IE11理解)最常见的编译器就是babeljs。
它与jquery无关。