HTML:
的index.html
<head>
<title>A Site</title>
</head>
<body>
</body>
berkeley.html
<template name="berkeley">
<div class="container">
<ul>
<!--nothing from the task template is displayed-->
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
<!--just testing without the template by accessing variable directly; still displays nothing-->
<ul>
{{#each tasks}}
<li>{{fullName}}</li>
{{/each}}
</ul>
</div>
</template>
JavaScript的:
logic.js
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
Template.body.helpers({
tasks: function() {
return Tasks.find({}, {sort: {createdAt: -1}});
}
});
}
当URL为&#39; / berkeley&#39;时,我使用Iron Router渲染Berkeley模板。
HTML似乎无法获取数组tasks
,该数组存在于JavaScript中并已填充。
task
模板有效,因为如果我排除{{#each tasks}}
和{{/each}}
Meteor能够在task
模板中显示静态内容,但在包含时,没有任何内容显示。
以下是Meteorpad:http://meteorpad.com/pad/HLWuxo3wMc54dQP33/Copy%20of%20Leaderboard (整个身体块都没有显示,在这种情况下;我很困惑)