流星来自测试版,我非常兴奋使用它。我将它安装在我的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错误:
Uncaught TypeError: Cannot read property 'helpers' of undefined
在流星控制台中,没有打印错误或警告。我对流星非常兴奋,我很乐意将它用于生产应用程序,所以请帮助我解决这个问题(可能非常简单)。我希望这不仅是Windows中的一个问题(流星尚未正式发布的Windows)。
我首先要做的是加上'console.dir(模板) ;'尝试调用'.helpers()'之前。问题在于'.body'是'undefined',因此找出'Template'的外观是很有用的。 – Pointy 2014-11-08 16:11:22