0

这可以编译,但如果我在最后删除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

/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|             
4

1 回答 1

1

你的代码对我来说很好。但是,在您的示例代码中,您没有使用 mixin ListItem。也许某些缩进是错误的。您甚至可以简化代码并使用迭代

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
于 2013-01-25T07:14:06.810 回答