[email protected]/1版本,Table组件IE9不兼容的问题

[email protected]/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);
                })
            };
        }
    });
}

问题解决了
这里写图片描述

猜你喜欢

转载自blog.csdn.net/zshsats/article/details/80285067
今日推荐