我一直收到错误
模板助手中的异常:ReferenceError:未定义线程
尝试迭代集合并将其打印到页面中。为了隔离问题,我已将其设置为为数据库中预加载的两个线程中的每个线程打印一个按钮。我收到错误,没有发布任何按钮。键入Threads.find()。count();在控制台中返回2.
我的代码如下
Meteor.startup(function () {
Threads = new Mongo.Collection('threads');
});
Template.threads.helpers({
threads: function() {
return Threads.find();
}
});
和
<body>
<div class="threads">
{{> threads}}
</div>
</body>
<template name="threads">
{{#each threads}}
<button>Button!</button>
{{/each}}
</template>
答案 0 :(得分:1)
尝试将您的收藏声明移出Meteor.startup
块。
我怀疑你的模板帮助器在Meteor.startup
触发之前首先被调用,从而引发了未定义的标识符错误。