【发布时间】:2014-11-09 00:51:58
【问题描述】:
Meteor 已完成测试版,我很高兴能使用它。我将它安装在我的 Windows 机器上(来自http://win.meteor.com/)并创建了一个应用程序。代码如下:
html:
<!-- simple-todos.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>
javascript:
// simple-todos.js
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: [
{ text: "This is task 1" },
{ text: "This is task 2" },
{ text: "This is task 3" }
]
});
}
它与official meteor tutorial 中的代码完全相同。如果我运行该示例,则标题会很好地呈现。另一方面,列表根本没有出现。不知何故,助手不起作用。我收到以下 javascript 错误:
未捕获的类型错误:无法读取未定义的属性“助手”
在流星控制台中,没有打印错误或警告。我对流星感到非常兴奋,我很想在未来将它用于生产应用程序,所以请帮助我解决这个(可能非常简单)的问题。我希望这不仅仅是windows中的问题(流星还没有正式发布windows)。
【问题讨论】:
-
我要做的第一件事是在尝试调用
.helpers()之前添加console.dir(Template);。问题是.body是undefined,所以弄清楚Template的实际样子会很有用。
标签: javascript meteor