簡體   English   中英

JS意外令牌

[英]JS Unexpected token else

我在這里有問題...

if (currentScreen=="object" && currentItem[1]!=null){
  gotoElement(currentItem[0], currentItem[1], true, false, currentScreen);
}  else  {
    loadContent("objectMain.php?objectClass=" + currentItem[0],"centerDiv");
} else {
    target=getTargetFromCurrentScreen(currentScreen);
    loadContent(target,"centerDiv"); 
}

enableWidget('menuBarRedoButton');
if (historyPosition == 0) {
    disableWidget('menuBarUndoButton');
}

錯誤是:

“其他意外令牌”。

有人可以幫助我嗎?

您必須使用else if()而不是兩個successif else

if (first_condition){

} else if(second_condition) {

} else {

}

希望這可以幫助。

你有這個:

if (someCondition) {

} else {

} else {

}

從邏輯上講這沒有任何意義。 else表示“在所有其他情況下”。 那么,什么將第二 else可能意味着什么?

你可能意味着有第二個 if條件:

if (someCondition) {

} else if (anotherCondition) {

} else {

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM