#anujs#anujs+webpack4+reach-router環境搭建過程當中遇到的BUG

對象不支持「hasOwnProperty」屬性或方法 在IE8中

老版本的 IE 的 DOM Element 是沒有 hasOwnProperty 方法的,
而且window 對象也沒有 hasOwnProperty 方法。
咱們可使用 Object 對象的 hasOwnProperty 。prototype

Object.prototype.hasOwnProperty.call(window, "property")
Object.prototype.hasOwnProperty.call(element, "property")

SCRIPT5009: 「Promise」未定義 在IE8中

'use strict';

    (function () {
        if (typeof Object.assign != 'function') {
            (function () {
                Object.assign = function (target) {
                    'use strict';
                    if (target === undefined || target === null) {
                        throw new TypeError('Cannot convert undefined or null to object');
                    }

                    var output = Object(target);
                    for (var index = 1; index < arguments.length; index++) {
                        var source = arguments[index];
                        if (source !== undefined && source !== null) {
                            for (var nextKey in source) {
                                if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
                                    output[nextKey] = source[nextKey];
                                }
                            }
                        }
                    }
                    return output;
                };
            })();
        }
    })();
相關文章
相關標籤/搜索