使用"reports.js“文件中的代码,在"reports.html”的同一文件夹中,返回数组中的0元素。不确定我是否遗漏了任何额外的声明,但我也不能使用“从‘meteor/ Mongo’中导入{mongo};”而没有错误“使用保留的单词'import'”。流星版本1.2.1
JS
Tasks = new Mongo.Collection('tasks');
if(Meteor.isClient){
Template.reports.rendered = function(){
if(Session.get("animateChild")){
$(".reports-page").addClass("ng-enter");
setTimeout(function(){
$(".reports-page").addClass("ng-enter-active");
}, 300);
setTimeout(function(){
$(".reports-page").removeClass("ng-enter");
$(".reports-page").removeClass("ng-enter-active");
}, 600);
}
};
}
Template.dashboardd.helpers({
options() {
return Tasks.find({});
},
});<Template name="dashboardd">
{{#each options}}
<p><label>{{text}}</label></p>
{{/each}}
</Template>发布于 2016-11-03 21:30:53
AFAIK流星1.2不支持进口。Improrts是新的模块,增加了I流星1.3或1.4我不确定。在处理集合时,我总是使用这3个元素(如果我们使用集合声明,则使用4个元素)。
您应该在服务器端执行一些发布,并允许如下所示:
Meteor.publish("Tasks ", function (selector, options) {
//you can remove condition if you dont have accounts-package
if (this.userId) {
return Tasks .find(selector || {}, options || {});
}
});如果你没有流星账户,你可以简单地返回true,插入,更新等。但是我不想说这是不安全的。
Tasks.allow({
insert: function (userId, doc) {
return userId;
},
update: function (userId, doc) {
return userId;
},
remove: function (userId) {
return userId;
},
});在客户端有一些订阅
Template.YourTemplateName.onCreated(function () {
this.autorun(() => {
this.subscribe('Tasks', { _id: Template.currentData()._id });
//or
this.subscribe('Tasks');
//but this solution can kill Browser when you collection will have a thousand elements. Allways try to not subscribe all collection. Only Needed fields/objects
});
});https://stackoverflow.com/questions/40408894
复制相似问题