我正在尝试在jade模板中显示一个基本的html表,但是我收到了这个错误:
Error: c:\2406Node\myapp\views\table.jade:7
5| table, th, td {
6| border: 1px solid black;
> 7| }
8| body
9| table(style="width:100%")
10| tr
unexpected text }
b
at Object.Lexer.fail (c:\2406Node\myapp\node_modules\jade\lib\lexer.js:872:11)
at Object.Lexer.next (c:\2406Node\myapp\node_modules\jade\lib\lexer.js:931:15)
at Object.Lexer.lookahead (c:\2406Node\myapp\node_modules\jade\lib\lexer.js:113:46)
at Parser.lookahead (c:\2406Node\myapp\node_modules\jade\lib\parser.js:102:23)
at Parser.peek (c:\2406Node\myapp\node_modules\jade\lib\parser.js:79:17)
at Parser.tag (c:\2406Node\myapp\node_modules\jade\lib\parser.js:810:30)
at Parser.parseTag (c:\2406Node\myapp\node_modules\jade\lib\parser.js:737:17)
at Parser.parseExpr (c:\2406Node\myapp\node_modules\jade\lib\parser.js:211:21)
at Parser.tag (c:\2406Node\myapp\node_modules\jade\lib\parser.js:797:29)
at Parser.parseTag (c:\2406Node\myapp\node_modules\jade\lib\parser.js:737:17)
这是我的玉文件,其中包含表格:
doctype html
html
head
style
table, th, td {
border: 1px solid black;
}
body
table(style="width:100%")
tr
th
th TA
th Start Date
th Deadline
th Completion Date
th Comment
tr
th A1
th Chris
td
td
td
td
tr
th
th Lucas
td
td
td
td
tr
th
th Muhammad
td
td
td
td
tr
th
th Lee
td
td
td
td
这是我转换为jade的html:
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th></th>
<th>TA</th>
<th>Start Date</th>
<th>Deadline</th>
<th>Completion Date</th>
<th>Comment</th>
</tr>
<tr>
<th>A1</th>
<th>Chris</th>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th></th>
<th>Lucas</th>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th></th>
<th>Muhammad</th>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th></th>
<th>Lee</th>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
只需要知道我做错了什么,以及jade是否需要更改我当前的代码才能正确显示表格。
答案 0 :(得分:1)
将样式的右括号拉到上一行:
style
table, th, td {
border: 1px solid black;}