Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor/Blaze模板$.Session_Session_Meteor_Meteor Blaze - Fatal编程技术网

Meteor/Blaze模板$.Session

Meteor/Blaze模板$.Session,session,meteor,meteor-blaze,Session,Meteor,Meteor Blaze,我正在遵循Meteor教程,该教程在Blaze模板中使用了$.Session.get,但它的行为不符合预期。模板应该计算会话变量,并显示表单或按钮。如果单击该按钮,会话变量将设置为true,并且表单将显示。那是不会发生的 我怀疑这是Meteor/Blaze版本控制问题,因为最近有很多变化。我使用的是Meteor1.4.2.1,我很确定本教程是针对Meteor1.2的 以下是模板片段: <template name="Recipes"> {{ #if $.Session.get new

我正在遵循Meteor教程,该教程在Blaze模板中使用了$.Session.get,但它的行为不符合预期。模板应该计算会话变量,并显示表单或按钮。如果单击该按钮,会话变量将设置为true,并且表单将显示。那是不会发生的

我怀疑这是Meteor/Blaze版本控制问题,因为最近有很多变化。我使用的是Meteor1.4.2.1,我很确定本教程是针对Meteor1.2的

以下是模板片段:

<template name="Recipes">
{{ #if $.Session.get newRecipe }}
  {{> NewRecipe }}
{{ else }}
  <button class="new-recipe">New Recipe</button>
{{ /if }}...
以下是相关的代码块:

// set the session var to false - hide the form, show the button
Template.NewRecipe.events({
  'click .fa-close': () => {
 Session.set('newRecipe', false);
  }
});

// set the session var to true - show the form, hide the button
Template.Recipes.events({
  'click .new-recipe': () => {
  Session.set('newRecipe', true);
  }
});

指向您正在使用的教程会很有用。似乎你正在使用的一些东西只是在这里定义的。给你,多亏了你的建议,我发现了部分问题。我在变量名周围没有引号。是否添加了
raix:handlebar helpers
程序包?是的,该程序包包含在程序包列表中console中无错误?你确定钥匙拼写正确吗?请张贴所有相关的代码,因为这应该是工作。为了确定,您是否将
会话
包添加到了项目中?
// set the session var to false - hide the form, show the button
Template.NewRecipe.events({
  'click .fa-close': () => {
 Session.set('newRecipe', false);
  }
});

// set the session var to true - show the form, hide the button
Template.Recipes.events({
  'click .new-recipe': () => {
  Session.set('newRecipe', true);
  }
});