Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Jade中重复引导容器?_Javascript_Json_Node.js_Express_Pug - Fatal编程技术网

Javascript 如何在Jade中重复引导容器?

Javascript 如何在Jade中重复引导容器?,javascript,json,node.js,express,pug,Javascript,Json,Node.js,Express,Pug,我有从Express和Mongoose堆栈发送的JSON数据,用于在Jade中编程的UI。 我应该使用什么Jade构造来使用Jade语法重复col-md-4的引导容器 目前我的玉码如下: if deal each item in deal .col-sm-6.col-md-4 .thumbnail img(alt='100%x200', src='#{item.image_url}', style='height: 250px; width: 100%;')

我有从Express和Mongoose堆栈发送的JSON数据,用于在Jade中编程的UI。 我应该使用什么Jade构造来使用Jade语法重复col-md-4的引导容器

目前我的玉码如下:

 if deal
each item in deal
  .col-sm-6.col-md-4
    .thumbnail
      img(alt='100%x200', src='#{item.image_url}', style='height: 250px; width: 100%;')
      .caption

        h3 
          | #{item.brand_id}
但我有个错误

Cannot read property 'image_url' of undefined
我的JSON数据是这样发送的

Deal.find(function(err, result){
    if(err) return console.log("Error" + err);
    res.render('home',{deal:result});
}))


从JSON格式的内容中重复数据块的可能解决方案是什么?

您的代码似乎正确,请确保“交易”中确实填充了正确的数据。 下面是一个工作示例:

- var list = [{x: 123, y: 234}, {x: 123, y: 234}];
each item in list
  .col-sm-6.col-md-4
    .thumbnail
      img(alt='100%x200', src='#{item.x}', style='height: 250px; width: 100%;')
      .caption

        h3
          | #{item.y}
输出:

<div class="col-sm-6 col-md-4">
  <div class="thumbnail"><img alt="100%x200" src="123" style="height: 250px; width: 100%;"/>
    <div class="caption">
      <h3>234</h3>
    </div>
  </div>
</div>
<div class="col-sm-6 col-md-4">
  <div class="thumbnail"><img alt="100%x200" src="123" style="height: 250px; width: 100%;"/>
    <div class="caption">
      <h3>234</h3>
    </div>
  </div>
</div>

234
234

您是否尝试实际定义
?否。deal是一个JSON数组对象,对于此数组对象的每次迭代,我都要重复上面的部分。如果deal确实是一个对象数组,您的代码应该可以正常工作。@NitsanBaleli我已编辑以显示服务器端发送数据的方式。让我试试。谢谢!:)这很有魅力!非常感谢D