【发布时间】:2015-02-24 21:12:41
【问题描述】:
我的 HTML 类似于这个
<template name="stop">
{{#each thumb}}
<tr>
<td class="image" ><img src="{{this.data}}"></td>
<td>
<center style="float:right; margin-bottom: 25%;">
<h2> Do you like this product? </h2>
<h2>{{this.text}}</h2></center>
</td>
</tr>
{{/each}}
</template>
这个模板是指我的模板助手,看起来像这样
Template.stop.helpers( {
'thumb': function(data) {
console.log(z);
return tweetImages.findOne()
})
tweetImage.findOne() 输出这个
Object {_id: "1", data: Array[7], text: Array[7]}
每次模板运行时,我都会尝试遍历两个数组中的每个项目,但每次都会输出每个数组的所有 7 个值。我知道这在某处需要上下文变量,但我无法解决。有人有什么想法吗?
【问题讨论】:
标签: javascript json meteor handlebars.js this