Problèmes de compatibilité IE (continuellement complétés)

1. Le format d'heure sous IE reconnaît NaN.

Raison : IE ne peut pas reconnaître le format aaaa-MM-jj et doit être converti au format aaaa/MM/jj.

//正则替换
replace(new RegExp(/-/gm) ,"/")

2. IE10- ne peut pas déclarer let const

3. IE8 n'est pas compatible avec le filtre

if (!Array.prototype.filter)
{
    Array.prototype.filter = function(fun /*, thisp */)
    {
        "use strict";

        if (this === void 0 || this === null)
            throw new TypeError();

        var t = Object(this);
        var len = t.length >>> 0;
        if (typeof fun !== "function")
            throw new TypeError();

        var res = [];
        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
        {
            if (i in t)
            {
                var val = t[i]; // in case fun mutates this
                if (fun.call(thisp, val, i, t))
                    res.push(val);
            }
        }

        return res;
    };
}

4. IE10-incompatible avec ajax de JQ.

// 全局声明以下代码
jQuery.support.cors = true;

5. Si IE doit être compatible avec @media, il doit écrire le css dans le fichier css, et l'écrire dans le style n'est pas valide

6. Taille d'arrière-plan : la couverture n'est pas valide sous IE

-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dist/images/registerBg.png',sizingMethod=scale); 
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dist/images/registerBg.png',sizingMethod=scale);

7. La surveillance des événements est entièrement compatible

/**
 * 添加事件监听 兼容IE8
 * @param el
 * @param type
 * @param fn
 */
function addListener(el, type, fn) {
    if (el.addEventListener) {
        el.addEventListener(type, fn, false);
    } else if (el.attachEvent) {
        el.attachEvent('on' + type, fn);
    }
}

/**
 * 移除事件监听 兼容IE8
 * @param el
 * @param type
 * @param fn
 */
function removeListener(el, type, fn) {
    if (el.removeEventListener) {
        el.removeEventListener(type, fn, false);
    } else if (el.detachEvent) {
        el.detachEvent('on' + type, fn);
    }
}

8. IE8 ne prend pas en charge l'indexOf des tableaux

if (!Array.prototype.indexOf){
    Array.prototype.indexOf = function(elt /*, from*/){
        var len = this.length >>> 0;

        var from = Number(arguments[1]) || 0;
        from = (from < 0)
            ? Math.ceil(from)
            : Math.floor(from);
        if (from < 0)
            from += len;

        for (; from < len; from++){
            if (from in this && this[from] === elt)
                return from;
        }
        return -1;
    };
}

 

Je suppose que tu aimes

Origine blog.csdn.net/QiZi_Zpl/article/details/105763690
conseillé
Classement