这个非常简单的应用程序无法正常工作。我的列表没有显示出来。为什么?我必须错过一些关于流星如何工作的重要内容。为什么我不能用Meteor渲染这个简单的列表?
recipes.html
<body>
<h3>Recipes</h3>
{{> recipes}}
</body>
<template name="recipes">
<ul>
{{#each recipes}}
<li>{{name}}</li>
{{/each}}
</ul>
</template>
recipes.coffee
Recipes = new Meteor.Collection("recipes")
if Meteor.is_client
Meteor.startup ->
Meteor.autosubscribe(->
Meteor.subscribe('recipes')
)
# THIS IS NOT WORKING
Template.recipes.recipes ->
return Recipes.find()
if Meteor.is_server
Meteor.startup ->
if Recipes.find().count() == 0
data = [
name: "Chocolate Chip Cookies"
,
name: "Spring Rolls"
]
for item in data
Recipes.insert(item)
Meteor.publish('recipes', ->
return Recipes.find()
)
错误
Uncaught TypeError: Object function (data) {
var getHtml = function() {
return raw_func(data, {
helpers: partial,
partials: Meteor._partials
});
};
var react_data = { events: (name ? Template[name].events : {}),
event_data: data,
template_name: name };
return Meteor.ui.chunk(getHtml, react_data);
} has no method 'recipes'
我已经autopubl试过这种ish和没有。我在这里不了解什么?
编辑:
我之前贴错代码,亚什德指出。现在的代码是有问题的代码。
你说得对,但这只是我在发布代码时犯的一个错误。我编辑了这个问题,现在只显示有问题的代码。 – peter 2012-08-10 19:49:46
'='呢?我认为你需要它。这是在1)。 – 2012-08-11 06:27:23