【发布时间】:2014-04-05 23:52:35
【问题描述】:
我正在运行 Meteor 0.8.0
尝试插入 Meteor 集合时,我从浏览器控制台收到 ReferenceError。仅供参考,我已删除此应用的自动发布包,以便使用发布和订阅。
模板
<head>
<title>itemsApp</title>
</head>
<body>
{{> name}}
{{> items}}
</body>
<template name="name">
<input type="text" />
</template>
<template name="items">
<h1>Items</h1>
<ul>
{{#each items}}
<li>{{name}} | {{category}}</li>
{{/each}}
</ul>
</template>
代码
var Items = new Meteor.Collection("items");
if (Meteor.isClient) {
Meteor.subscribe("items");
Template.items.items = function () {
return Items.find();
};
}
if (Meteor.isServer) {
Meteor.publish("items", function () {
return Items.find();
});
}
现在,从浏览器控制台(Ubuntu 13.10 上的 FF28 和 Chromium 33.0.1750.152),我得到了
ReferenceError: 项目未定义
当我跑步时:
Items.insert({name: "iPod", category : "Apple"});
有什么想法吗?
谢谢!
【问题讨论】:
标签: javascript collections meteor referenceerror