我在获取非常简单的流星教程以阅读Mongodb中的收藏并将其打印到页面时遇到了麻烦。这是在流星网站上找到的官方教材。任何帮助将非常感激。如果有人想连接到工作区并进行更改,请告诉我,我可以授予访问权限。
这是我的工作区的链接:https://ide.c9.io/hilldesigns/meteor
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: function () {
return Tasks.find({});
}
});
}
这是HTML标记:
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
最佳答案
不确定是否要在身体上附加辅助对象,1.2.1(最新版本)不支持该辅助对象。如果您在浏览器中打开控制台,它将显示一条错误消息,关于无法访问未定义的助手。
所以,要使其工作...
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
{{> todos}}
</div>
</body>
<template name="todos">
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</template>
<template name="task">
<li>{{text}}</li>
</template>
与
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.todos.helpers({
tasks: function () {
return Tasks.find({});
}
});
}
工作良好
这是我的流星清单
autopublish 1.0.4 (For prototyping only) Publish the entire database to all clients
blaze-html-templates 1.0.1 Compile HTML templates into reactive UI with Meteor Blaze
ecmascript 0.1.6* Compiler plugin that supports ES2015+ in all .js files
es5-shim 4.1.14 Shims and polyfills to improve ECMAScript 5 support
insecure 1.0.4 (For prototyping only) Allow all database writes from the client
jquery 1.11.4 Manipulate the DOM using CSS selectors
meteor-base 1.0.1 Packages that every Meteor app needs
mobile-experience 1.0.1 Packages for a great mobile user experience
mongo 1.1.3 Adaptor for using MongoDB and Minimongo over DDP
session 1.1.1 Session variable
standard-minifiers 1.0.2 Standard minifiers used with Meteor apps by default.
tracker 1.0.9 Dependency tracker to allow reactive callbacks
流星是1.2.1