模板助手中的Meteor quickForm异常:错误:配方不在窗口范围内

问题描述 投票:2回答:2

我无法让应用程序在Meteor上运行。 quickform没有链接我的Collection。

“模板助手中的异常:错误:配方不在窗口范围内”

有人可以帮到这里吗?

这是我的quickform代码

<template name="NewRecipe">
	<div class="new-recipe-container">
		{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert" class="new-recipe-form" }}
		
	</div>
</template>

这是我的集合架构

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 );
javascript html meteor meteor-blaze meteor-autoform
2个回答
5
投票

我无法对你的问题发表评论,因为我的声誉不到50,所以我将其作为答案发布。

我正在遵循相同的中间流星Level Up Tuts,但是因为我正在使用Meter 1.3而试图遵循new Application structure and import syntax,我想要遵循最新的最佳实践。

我有这个错误,因为当我试图写

{{> 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问题)。点我的收藏品不在全球范围内。所以我必须编写一个模板助手来返回集合并编写quickForm模板包含如下:

collection =食谱(不含报价单)

现在,食谱是一个模板助手,它返回食谱集合对象

Template.NewRecipe.helpers({
  Recipes(){
    return Recipes;
  }
});

我从here了解了这个问题

但是既然你正在使用Meteor的旧应用程序结构方法(我猜?)Meteor仍在支持,那么我现在只能想到一个问题,即最新版本的autoform是专为Meteor 1.3而设计的。 。我搜索了Meteor论坛,我得到了一个有同样关注的post

你可以尝试两件事:

  1. 尝试他所做的修复这些全局错误,即显式地将集合添加到窗口对象。
  2. 尝试像他一样恢复到旧版本的autoform。

也许让我知道每个人的发现?


0
投票

有必要改变aldeed:[email protected]并输入你的“版本”。

aldeed:[email protected]

在包中,还需要插入:

accounts-ui accounts-password

aldeed:collection2 aldeed:autoform aldeed:simple-schema

© www.soinside.com 2019 - 2024. All rights reserved.