這個非常簡單的應用程序無法正常工作。我的列表沒有顯示出來。爲什麼?我必須錯過一些關於流星如何工作的重要內容。爲什麼我不能用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