[email protected]/1版本,Table组件IE9不兼容的问题
程序员文章站
2022-05-28 12:48:34
...
aaa@qq.com/1版本,Table组件IE9不兼容的问题
问题描述:
IE9下出现错误:
查找原因:
查看iview github上源码:是因为remove方法不兼容IE9引起的
if(this.showVerticalScrollBar){
bodyEl.classList.add(this.prefixCls +'-overflowY');
}else{
bodyEl.classList.remove(this.prefixCls +'-overflowY');
}
if(this.showHorizontalScrollBar){
bodyEl.classList.add(this.prefixCls +'-overflowX');
}else{
bodyEl.classList.remove(this.prefixCls +'-overflowX');
}
解决办法:
if (!("classList" in document.documentElement)) {
Object.defineProperty(HTMLElement.prototype, 'classList', {
get: function() {
var self = this;
function update(fn) {
return function(value) {
var classes = self.className.split(/\s+/g),
index = classes.indexOf(value);
fn(classes, index, value);
self.className = classes.join(" ");
}
}
return {
remove: update(function(classes, index) {
if (~index) classes.splice(index, 1);
})
};
}
});
}
问题解决了