首页 > 解决方案 > 在高端 PC 上加载网页时,从 Retina.js 收到一些错误

问题描述

我是 JQuery 的初学者,在高端 PC 上测试我的 Web 应用程序时(特别是在使用 windows 10 设置scale and layout>change the size of text apps and other items为 150% 时)' retina.min.js '显示以下功能的一些错误

功能一

function r(e, t) {
    try {
        this.path = e;
        if (typeof t !== "undefined" && t !== null) {
            this.at_2x_path = t;
            this.perform_check = false
        } else {
            this.at_2x_path = e.replace(/\.\w+$/, function (e) {
                return "@2x" + e
            });
            this.perform_check = true
        }
    }
    catch (err) {
        alert("Function 1" + err.message);
    }
}

错误:功能 1:无法读取 null 的属性“替换”

功能二

r.prototype.check_2x_variant = function (e) {
    try {
        var n, i = this;
        if (this.is_external()) {
            return e(false)
        } else if (!this.perform_check && typeof this.at_2x_path !== 
"undefined" && this.at_2x_path !== null) {
            return e(true)
        } else if (this.at_2x_path in r.confirmed_paths) {
            return e(true)
        } else {
            n = new XMLHttpRequest;
            n.open("HEAD", this.at_2x_path);
            n.onreadystatechange = function () {
                if (n.readyState != 4) {
                    return e(false)
                }
                if (n.status >= 200 && n.status <= 399) {
                    if (t.check_mime_type) {
                        var s = n.getResponseHeader("Content-Type");
                        if (s == null || !s.match(/^image/i)) {
                            return e(false)
                        }
                    }
                    r.confirmed_paths.push(i.at_2x_path);
                    return e(true)
                } else {
                    return e(false)
                }
            };
            n.send()
        }
    } catch (err) {
        alert("Function 5 :" + err.message);
    }
};

错误:函数 5:无法读取 null 的属性“匹配”

浏览器控制台上的错误消息

retina.min.js:1 Uncaught TypeError: Cannot read property 'replace' of null
at new r (retina.min.js:1)
at new i (retina.min.js:1)
at t.onload (retina.min.js:1)
r @ retina.min.js:1
i @ retina.min.js:1
t.onload @ retina.min.js:1
load (async)
n.init @ retina.min.js:1
(anonymous) @ retina.min.js:1
(anonymous) @ retina.min.js:1

为什么会这样?

它是一个插件,我不知道它是如何工作的,所以我不想把它搞砸。请帮助我..我应该改变什么?

标签: jqueryretina

解决方案


推荐阅读