0
node.js新手我使用快遞生成了一個簡單的網站。我已經添加了以下文字index.jade
:如何在玉模板中使用else語句?
raining = true
if(raining === true)
p It is raining. Take an umbrella!
else
p No rain. Take the bike!
當我註釋掉最後兩個語句,我得到預期的迴應:「下雨了帶上雨傘。!」
當我包括最後兩行,我得到一個意外的標記錯誤:
Unexpected token (57:0)
SyntaxError: Unexpected token (57:0)
at Parser.pp.raise (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:943:13)
at Parser.pp.unexpected (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1503:8)
at Parser.pp.parseExprAtom (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:327:12)
at Parser.pp.parseExprSubscripts (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:216:19)
at Parser.pp.parseMaybeUnary (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:197:19)
at Parser.pp.parseExprOps (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:151:19)
at Parser.pp.parseMaybeConditional (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:133:19)
at Parser.pp.parseMaybeAssign (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:110:19)
at Parser.pp.parseExpression (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:86:19)
at Parser.pp.parseStatement (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1750:23)
不知道爲什麼else語句列入可能導致錯誤。任何建議將不勝感激。
你能否提供實際的代碼片段。瞭解錯誤發生的位置會更容易。 –
這個問題是關於一個玉模板中的else語句,而不是關於快速編輯標題中的else語句。 – jfriend00