簡體   English   中英

模板幫助器中的Meteor quickForm異常:錯誤:配方不在窗口范圍內

[英]Meteor quickForm Exception in template helper: Error: Recipes is not in the window scope

我無法在Meteor上運行該應用程序。 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 ); 

我的聲譽不到50,因此無法評論您的問題,因此我將其發布為答案。

我正在遵循相同的中間流星“ Level Up Tuts”,但是嘗試遵循新的“應用程序”結構並導入語法,因為我使用的是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問題)。 要點是我的收藏不在全球范圍內 因此,相反,我不得不編寫一個模板助手來返回該集合並編寫quickForm模板包含項,如下所示:

collection =配方(不帶引號)

現在,這里的“ 食譜”是一個模板助手,它返回“食譜”集合對象

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

我從這里開始了解這個問題

但是由於您使用的是Meteor仍支持的Meteor的較舊的應用程序結構方法(我想?),所以我現在可能只想到一個問題,因為最新版本的autoform專為Meteor 1.3設計。 我搜索了流星論壇,並得到了同樣關注的帖子

您可以嘗試兩件事:

  1. 嘗試他為解決這些全局錯誤所做的工作,即,將集合顯式添加到window對象。
  2. 嘗試像他一樣還原到舊版本的自動表單。

也許讓我知道每個發現的結果?

有必要更改aldeed:collection2@3.0.2並放入您的“版本”。

aldeed:collection2@3.0.0

在軟件包中,還需要插入:

帳戶-ui帳戶密碼

aldeed:collection2 aldeed:autoform aldeed:simple-schema

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM