【发布时间】:2012-09-08 08:16:45
【问题描述】:
我正在尝试迭代 Jade 中的一组数组。我似乎已经达到了极限。
div().slidePreview
ul
each slide in slides
div
each section in slide
li
each image in section
img(class= image.orientation, src='http://stevepainter.s3.amazonaws.com/images/thumbs/' + image.filename)
少了一次迭代,它就可以正常工作(即幻灯片 [0] 中的每个部分)。如果我 console.log(image) 我得到完整的对象。如果我 console.log(image.orientation) 我得到方向,但在浏览器中我得到:-
18| each image in section 19| -console.log(image.orientation) 20| img(class= image.orientation, src='http://stevepainter.s3.amazonaws.com/images/thumbs/' + image.filename) 21| Cannot read property 'orientation' of undefined> 18| each image in section 19| -console.log(image.orientation) 20| img(class= image.orientation, src='http://xxxxxxxxxxxxx.s3.amazonaws.com/images/thumbs/' + image.filename) 21| Cannot read property 'orientation' of undefined>
请帮帮我,这可要了我的命!!!!
【问题讨论】:
-
请使用正确的代码语法。这是不可读的。
-
如果用不同类型(更简单)的嵌套元素替换它会发生什么?这会告诉你它是深度还是嵌套元素有什么特别的问题。
-
ksol 这是正确的语法 - 它是 Jade。
-
ksol 指的是您没有使用正确的 Markdown 语法来格式化您的帖子,以便您的代码以您编写的方式显示,而不是显示为一团未格式化的文本 (例如,如果您没有以至少四个空格开始每一行,那么您的所有缩进都会消失)。 Bergi 非常友好地编辑了您的帖子并重新格式化,以便现在可以阅读。
标签: javascript arrays node.js express pug