我无法让应用程序在Meteor上运行。 quickform没有关联我的收藏。
"模板帮助器中的异常:错误:食谱不在窗口范围内"
任何人都可以在这里帮忙吗?
这是我的快速格式代码
<template name="NewRecipe">
<div class="new-recipe-container">
{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert" class="new-recipe-form" }}
</div>
</template>
&#13;
这是我的集合架构
Recipes = new Mongo.Collection('recipes');
RecipeSchema = new SimpleSchema({
name: {
type: String,
label:"Name"
},
desc: {
type: String,
label:"Description"
},
author: {
type: String,
label:"Author",
autoValue: function() {
return this.userId
}
},
createdAt: {
type: Date,
label:"Created At",
autoValue: function() {
return new Date()
}
}
});
Recipes.attachSchema( RecipeSchema );
&#13;
答案 0 :(得分:5)
我无法对您的问题发表评论,因为我的声誉不到50,所以我将此作为答案发布。
我正在关注相同的中间流星Level Up Tuts,但是我试图遵循new Application structure and import syntax,因为我正在使用Meter 1.3,我想要遵循最新的最佳实践。
我有这个错误,因为当我试图写
时{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert" class="new-recipe-form" }}
即。
collection =“食谱”(带引号)
这是一个问题,因为在Meteor 1.3中,由于es2015模块,Meteor 1.3中没有“全局”的东西了。我没有像你那样定义Collection(和Level Up Tuts中的Scott一样),我用一个 const 声明定义了Collection并用ec2015模块语法导出它(参见github问题我已提供)。 Point is my Collection不在全局范围中。因此,我必须编写一个模板助手来返回集合并编写quickForm模板包含,如下所示:
collection =食谱(不含引号)
现在食谱这里是一个模板帮助器,它返回食谱集合对象
Template.NewRecipe.helpers({
Recipes(){
return Recipes;
}
});
我从here
了解了这个问题但是既然你正在使用Meteor的旧应用程序结构方法(我猜?)Meteor仍在支持,那么我现在可能只能想到一个问题,最新版本的autoform是专为Meteor设计的1.3记住。我搜索了Meteor论坛,我得到了一个同样关注的post。
您可以尝试两件事:
也许让我知道每个人的发现?
答案 1 :(得分:0)
有必要更改aldeed:collection2@3.0.2
并放入您的“版本”。
aldeed:collection2@3.0.0
在包装中,还必须插入:
accounts-ui 帐户密码
aleded:collection2 aldeed:autoform aldeed:simple-schema