这会编译,但如果我删除最后的div
,则会抛出错误。我正在使用codekit进行编译。我没有到这里来的是什么?为什么额外div
重要?
mixin ListItemDetail(labels,values)
.listItemSection
.listItemDetailWrap
.listItemDetail #{labels[0]} :
.listItemDetail #{values[0]}
.listItemDetailWrap
.listItemDetail #{labels[1]} :
.listItemDetail #{values[1]}
.listItemDetailWrap
.listItemDetail #{labels[2]} :
.listItemDetail #{values[2]}
mixin ListItem()
.listItem
.listItemSection
h2 48 barrels of Kansas Common by 00/00/0000
small Ellsworth County, Kasas, 38.4500° N 96.5333° W
mixin ListItemDetail(['Start Date', 'End Date', 'Pickup Deadline'], ['00/00/0000', '00/00/0000', '00/00/0000'])
mixin ListItemDetail(["Bulletin", "Grade", "Join Deadline"], ["Plains", "Light Crude", "00/00/0000"])
mixin ListItemDetail(["API", "BS&W", "Sulfur"], ["48°", "4%", "0.1%"])
div
如果缺少最终div
,则这是codekit日志中发生的错误:
/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/runtime.js:173
throw err;
^
Error: /Users/isaac/Radiant/DemandPoint/dpe-grails/web-app/jade/Elements/ListItem.jade:23
21| mixin ListItemDetail(["API", "BS&W", "Sulfur"], ["48°", "4%", "0.1%"])
22|
> 23|
答案 0 :(得分:1)
您的代码适用于我。但是,在您的示例代码中,您没有使用mixin ListItem
。也许一些缩进是错误的。您甚至可以简化代码并使用iteration:
mixin ListItemDetail(labels,values)
each label,i in labels
.listItemSection
.listItemDetailWrap
.listItemDetail #{label} :
.listItemDetail #{values[i]}
mixin ListItem
.listItem
.listItemSection
h2 48 barrels of Kansas Common by 00/00/0000
small Ellsworth County, Kasas, 38.4500° N 96.5333° W
mixin ListItemDetail(['Start Date', 'End Date', 'Pickup Deadline'], ['00/00/0000', '00/00/0000', '00/00/0000'])
mixin ListItemDetail(["Bulletin", "Grade", "Join Deadline"], ["Plains", "Light Crude", "00/00/0000"])
mixin ListItemDetail(["API", "BS&W", "Sulfur"], ["48°", "4%", "0.1%"])
mixin ListItem // use your mixin here