【发布时间】:2017-06-27 17:10:21
【问题描述】:
我是 MeteorJS 的新手。我尝试使用以下代码在客户端视图中显示 MongoDB 集合。
client/main.js
Resolutions = new Mongo.Collection('resolutions');
Template.body.helpers({
resolutions : function(){
return Resolutions.find();
}
});
client/main.html(此处使用blaze)
<head>
<title>resolutions</title>
</head>
<body>
<ul>
{{#each resolutions}}
{{>resolution}}
{{/each}}
</ul>
</body>
<template name="resolution">
<li>{{title}}</li>
</template>
然后我使用流星 mongo shell 将一些对象插入到集合中
db.resolutions.insert({title:"test", createdAt:new Date()});
我测试天气对象被插入到集合中使用
db.resolutions.find()
输出是,
{
"_id": ObjectId("589c8d1639645e128780c3b4"),
"title": "test",
"createdAt": ISODate("2017-02-09T15:39:02.216Z")
}
但在客户端视图中,对象标题未按预期显示在列表中。而是查看一个空屏幕。
【问题讨论】:
标签: javascript node.js mongodb meteor meteor-blaze