【发布时间】:2017-01-20 08:43:19
【问题描述】:
我正在学习 Express 和使用 jam 的模板。我编写了非常简单的代码,但我遇到了错误。请告诉我有什么问题。
错误:
500 SyntaxError: Unexpected token (41:5)
at Parser.pp$4.raise (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:2422:15)
at Parser.pp.unexpected (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:613:10)
at Parser.pp.semicolon (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:590:61)
at Parser.pp$1.parseExpressionStatement (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:1002:10)
at Parser.pp$1.parseStatement (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:767:22)
at Parser.pp$1.parseTopLevel (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:655:25)
at Parser.parse (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:525:17)
at Object.parse (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn\dist\acorn.js:3300:39)
at reallyParse (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn-globals\index.js:22:16)
at findGlobals (H:\NodeJS-Lynda\Chap-5\06\start\node_modules\jade\node_modules\with\node_modules\acorn-globals\index.js:35:11)
layout.jade:
doctype html
html
head
title= title
link(rel="stylesheet", href="bootstrap.min.css")
body
div.container
block content
list.jade:
我尝试使用以下代码块,但在这两种情况下都出现此错误:
- 试用:
extends layout
block content
h1= title
ul
each flight, index in flights
- flight = flight.getInformation()
li= flight.number + ': ' + flight.origin + '-' + flight.destination
- 试用:
extends layout
block content
h1= title
ul
- each flight in flights
- flight= flight.getInformation()
li= flight.number + ':' + flight.origin + '-' + flight.destination
getInformation() 是我在另一个模块flight 中编写的方法。 flight 的参数是从调用 list.jade 的 js 文件传递的。
请任何人帮我解决这个问题。似乎有一些语法错误,但我不明白吗?谢谢。
【问题讨论】:
标签: javascript node.js express pug