我觉得应该给IE里的问题单独列一个专辑了,这浏览器什么时候彻底退出历史舞台啊。。。
用https://www.caniuse.com/这个网站看,ie是不支持forEach语法的,但是vue貌似对forEach进行了包装还是怎么的,反正ie11是支持的。但是我的代码仍然光荣牺牲在了IE下:
let popupEle = popup.$children[0].$children[1].$el let headerPart = popupEle.getElementsByClassName("ant-modal-header")[0] let contentPart = popupEle.getElementsByClassName("ant-modal-body")[0] let fixedElementsHeight = headerPart.offsetHeight + 30 let variablePart = null contentPart.childNodes.forEach(function (node) { if(node.id != "manageRelationsPart") { fixedElementsHeight += node.offsetHeight } else { variablePart = node } })
forEach那行报错了,百思不得其解。盯着断点看了30s钟,终于顿悟这里的childNodes是一个NodeList,对,IE不支持这个NodeList的forEach。。。
最后还是乖乖用for循环了,经典用法宝刀不老啊。。。