未捕获的类型错误:o.widget 不是 mouse.min.js Wordpress 的函数

Tom*_*kas 5 javascript wordpress jquery typeerror

经过移动友好测试后,我在 Wordpress 网站中发现了一个错误。

未捕获的类型错误:o.widget 不是 domain/wp-includes/js/jquery/ui/mouse.min.js?ver=1.11.4:11:163 处的函数

该文件中的代码是:

!(function (e) {
    "function" == typeof define && define.amd ? define(["jquery", "./widget"], e) : e(jQuery);
})(function (o) {
    var u = !1;
    return (
        o(document).mouseup(function () {
            u = !1;
        }),
        o.widget("ui.mouse", {
            version: "1.11.4",
            options: { cancel: "input,textarea,button,select,option", distance: 1, delay: 0 },
            _mouseInit: function () {
                var t = this;
                this.element
                    .bind("mousedown." + this.widgetName, function (e) {
                        return t._mouseDown(e);
                    })
                    .bind("click." + this.widgetName, function (e) {
                        if (!0 === o.data(e.target, t.widgetName + ".preventClickEvent")) return o.removeData(e.target, t.widgetName + ".preventClickEvent"), e.stopImmediatePropagation(), !1;
                    }),
                    (this.started = !1);
            },
            _mouseDestroy: function () {
                this.element.unbind("." + this.widgetName), this._mouseMoveDelegate && this.document.unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
            },
            _mouseDown: function (e) {
                if (!u) {
                    (this._mouseMoved = !1), this._mouseStarted && this._mouseUp(e), (this._mouseDownEvent = e);
                    var t = this,
                        s = 1 === e.which,
                        i = !("string" != typeof this.options.cancel || !e.target.nodeName) && o(e.target).closest(this.options.cancel).length;
                    return (
                        !(s && !i && this._mouseCapture(e)) ||
                        ((this.mouseDelayMet = !this.options.delay),
                        this.mouseDelayMet ||
                            (this._mouseDelayTimer = setTimeout(function () {
                                t.mouseDelayMet = !0;
                            }, this.options.delay)),
                        this._mouseDistanceMet(e) && this._mouseDelayMet(e) && ((this._mouseStarted = !1 !== this._mouseStart(e)), !this._mouseStarted)
                            ? (e.preventDefault(), !0)
                            : (!0 === o.data(e.target, this.widgetName + ".preventClickEvent") && o.removeData(e.target, this.widgetName + ".preventClickEvent"),
                              (this._mouseMoveDelegate = function (e) {
                                  return t._mouseMove(e);
                              }),
                              (this._mouseUpDelegate = function (e) {
                                  return t._mouseUp(e);
                              }),
                              this.document.bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate),
                              e.preventDefault(),
                              (u = !0)))
                    );
                }
            },
            _mouseMove: function (e) {
                if (this._mouseMoved) {
                    if (o.ui.ie && (!document.documentMode || document.documentMode < 9) && !e.button) return this._mouseUp(e);
                    if (!e.which) return this._mouseUp(e);
                }
                return (
                    (e.which || e.button) && (this._mouseMoved = !0),
                    this._mouseStarted
                        ? (this._mouseDrag(e), e.preventDefault())
                        : (this._mouseDistanceMet(e) && this._mouseDelayMet(e) && ((this._mouseStarted = !1 !== this._mouseStart(this._mouseDownEvent, e)), this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e)), !this._mouseStarted)
                );
            },
            _mouseUp: function (e) {
                return (
                    this.document.unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate),
                    this._mouseStarted && ((this._mouseStarted = !1), e.target === this._mouseDownEvent.target && o.data(e.target, this.widgetName + ".preventClickEvent", !0), this._mouseStop(e)),
                    (u = !1)
                );
            },
            _mouseDistanceMet: function (e) {
                return Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >= this.options.distance;
            },
            _mouseDelayMet: function () {
                return this.mouseDelayMet;
            },
            _mouseStart: function () {},
            _mouseDrag: function () {},
            _mouseStop: function () {},
            _mouseCapture: function () {
                return !0;
            },
        })
    );
});
Run Code Online (Sandbox Code Playgroud)

也许对 js 和 jquery 有更好了解的人可以看到问题出在哪里以及如何解决?

vol*_*ulz 0

jquery-ui-mouse 依赖于 jquery-ui-widget,而 jquery-ui-widget 又依赖于 jquery-ui-core,而 jquery-ui-core 又依赖于 jquery。因此,它们需要以正确的顺序排队。

  1. jQuery
  2. jquery-ui-核心
  3. jquery-ui-小部件
  4. jquery-ui-鼠标