1

我们有这个不可重现但偶然发生的有线错误。它在 Jquery 中的这一行/函数上引发错误: 代理:函数(fn,上下文) {

这是触发此问题的代码。它用于屏幕旋转,它在setTimeout($.proxy(function... :

    _showPanel: function(index) {
        // go to first panel, index is out of range
        var index = (index > this._panels.length - 1) ? 0 : index,

        // calculate next panel index
            nextIndex = (index + 1) % this._panels.length,
            panel = this._panels[index],
            oldPanelElement = this._currentPanelElement;


        // set timer when to switch to next panel
        this._panelRotationTimeout = **setTimeout($.proxy**(function () {
            if (this && this._showPanel) {
                this._showPanel(nextIndex);
            }
        }, this), panel.time);


        // hide old panel
        if (oldPanelElement) {
            oldPanelElement
                .hide()
                .detach();
        }

        // show/hide animation
        if (panel.animation) {
            this._animation.show();
        } else {
            this._animation.hide();
        }

        // show new panel
        this.element.find('.panelContainer')
            .append(panel.element);
        panel.element.show();

        // update status and button
        this._updateDisplay();

        // track current panel details
        this._currentPanelIndex = index;
        this._currentPanelElement = panel.element;

        this._currentDeviceStatusIndex = index;
    },
4

1 回答 1

0

setTimeout的第一个参数应该是一个函数。在您的示例中,您实际上是在调用 $.proxy 并给出setTimeout$.proxy 函数的返回值。尝试向它传递一个匿名函数并在其中执行您的操作:

setTimeout ( function() { $.proxy ( ...
于 2013-09-24T16:07:38.743 回答