我覺得應該給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循環了,經典用法寶刀不老啊。。。