[英]Error in Javascript: Unexpected token (
我的頁面拋出了一個javascript錯誤,但我無法弄清楚為什么。 我正在嘗試調試導入到客戶端站點的腳本。 它在這里拋出錯誤:
function(t){
e._trigger("receive",t,this._uiHash(this))
}
錯誤是“Uncaught SyntaxError:Unexpected token(”
對於上下文,這里是它所在的代碼塊。不幸的是,我真的不知道這些函數的用途是什么,但錯誤是阻止頁面正確加載。 希望這個Javascript足以給出上下文,完整的腳本很長。
_clear: function(e, t) {
this.reverting = !1;
var i, n = [];
if (!this._noFinalSort && this.currentItem.parent().length && this.placeholder
.before(this.currentItem), this._noFinalSort = null, this.helper[0] ===
this.currentItem[0]) {
for (i in this._storedCSS)
("auto" === this._storedCSS[i] || "static" === this._storedCSS[
i]) && (this._storedCSS[i] = "");
this.currentItem.css(this._storedCSS).removeClass(
"ui-sortable-helper")
} else this.currentItem.show();
for (this.fromOutside && !t && n.push(function(e) {
this._trigger("receive", e, this._uiHash(this.fromOutside))
}), !this.fromOutside && this.domPosition.prev === this.currentItem
.prev().not(".ui-sortable-helper")[0] && this.domPosition.parent ===
this.currentItem.parent()[0] || t || n.push(function(e) {
this._trigger("update", e, this._uiHash())
}), this !== this.currentContainer && (t || (n.push(function(e) {
this._trigger("remove", e, this._uiHash())
}), n.push(function(e) {
return
function(t) {
e._trigger("receive", t, this._uiHash(this))
}
}.call(this, this.currentContainer)), n.push(function(e) {
return
function(t) {
e._trigger("update", t, this._uiHash(this))
}
}.call(this, this.currentContainer)))), i = this.containers.length -
1; i >= 0; i--) t || n.push(function(e) {
return function(t) {
e._trigger("deactivate", t, this._uiHash(this))
}
}.call(this, this.containers[i])), this.containers[i].containerCache
.over && (n.push(function(e) {
return
function(t) {
e._trigger("out", t, this._uiHash(this))
}
}.call(this, this.containers[i])), this.containers[i].containerCache
.over = 0);
if (this.storedCursor && (this.document.find("body").css("cursor", this
.storedCursor), this.storedStylesheet.remove()), this._storedOpacity &&
this.helper.css("opacity", this._storedOpacity), this._storedZIndex &&
this.helper.css("zIndex", "auto" === this._storedZIndex ? "" : this
._storedZIndex), this.dragging = !1, this.cancelHelperRemoval) {
if (!t) {
for (this._trigger("beforeStop", e, this._uiHash()), i = 0; n.length >
i; i++) n[i].call(this, e);
this._trigger("stop", e, this._uiHash())
}
return this.fromOutside = !1, !1
}
if (t || this._trigger("beforeStop", e, this._uiHash()), this.placeholder[
0].parentNode.removeChild(this.placeholder[0]), this.helper[0] !==
this.currentItem[0] && this.helper.remove(), this.helper = null, !t
) {
for (i = 0; n.length > i; i++) n[i].call(this, e);
this._trigger("stop", e, this._uiHash())
}
return this.fromOutside = !1, !0
}
如果你想查看頁面,它就在這里
代碼的每個部分看起來像:
return
function(t) {
e._trigger("out", t, this._uiHash(this))
}
被打破。 JavaScript自動分號插入的規則是這樣的,當解析器到達換行符時,這些return
語句被視為完整。 它必須看起來像:
return function(t) {
e._trigger("out", t, this._uiHash(this))
}
這可能看起來令人驚訝,但這是真的。 您正在獲得的錯誤是因為解析器認為該function
關鍵字正在打開一個新的函數聲明語句,並且在這樣的語句中,函數名稱不是可選的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.