[英]How to apply array of images to a template helper in Meteor.js
我目前正在尝试将图像数组应用于模板HTML。
var z = [...jpg,...,jpg,...jpg];
var x = ["text","text","text"];
这些数组全局存储在我的文件中。
这是我的模板帮助器函数,我仅使用示例索引来查看它是否将显示在HTML中,但不能正常工作。
Template.stop.helpers({
'thumb': function(){
return z[1];
},
'snippet': function(){
return x[1];
}
});
这是我的html模板参考
<template name="stop">
<tr>
<td class="image"><img src="{{thumb}}"></td>
<td>
<center>
<h2> Do you like this product? </h2>
<i class="fa fa-check-square-o" style=" font-size: 50px; font-size=50px; margin-top: 50; padding-top: 5px;"></i>
<h3>{{title}}</h3>
<h2>{{snippet}}</h2>
</td>
</tr>
</template>
这是我体内的div中引用的位置
<div class="bottom">
{{> stop}}
</div>
我希望这些图像显示在HTML的表格中,但我什至无法显示。 有任何想法吗?
代码似乎可以删除var
关键字,也许在z x2上重复了吗?
z = [...jpg,...,jpg,...jpg];
x = ["text","text","text"];
如果您有指向/public
文件夹的图像数组,请同时添加它。
<td class="image"><img src="public/{{thumb}}"></td>
更新
if(Meteor.isClient){
z = [...jpg,...,jpg,...jpg];
x = ["text","text","text"];
for(var i=0;i<z.length;i++){
console.log(z[i])
}
Template.stop.helpers({
'thumb': function(){
console.log(z[1];
return z[1];
},
'snippet': function(){
return x[1];
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.