Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.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 流星计划/流星向导_Meteor - Fatal编程技术网

Meteor 流星计划/流星向导

Meteor 流星计划/流星向导,meteor,Meteor,Planifica/meteor向导的文档说明SimpleSchema应该作为模板的一部分创建。我把我所有的简单模式都作为我收藏的一部分,并希望保持这种状态。有人知道这是否可以通过Planifica/meteor wizard实现吗?无论您在哪里定义它都不重要。但是在查看流星向导文档时,看起来你至少需要一个引用 因此,您只需返回对它的引用,而不是定义模式的帮助器。因此,如果您使用文档示例。而不是: Template.setupStepOne.schema = function() { ret

Planifica/meteor向导的文档说明SimpleSchema应该作为模板的一部分创建。我把我所有的简单模式都作为我收藏的一部分,并希望保持这种状态。有人知道这是否可以通过Planifica/meteor wizard实现吗?

无论您在哪里定义它都不重要。但是在查看流星向导文档时,看起来你至少需要一个引用

因此,您只需返回对它的引用,而不是定义模式的帮助器。因此,如果您使用文档示例。而不是:

Template.setupStepOne.schema = function() {
  return new SimpleSchema({
    ...
  });
}
您可以使用:

Template.setupStepOne.schema = CollectionName.Schema;
只需将CollectionName.Schema替换为存储模式的任何位置。

Install first$meteor add planifica:wizard
Install first $ meteor add planifica:wizard

Please check bellow added small program. I think it is helpful for you.
<template name="setupWizard">
  {{> wizard id="setup-wizard" steps=steps}}
</template>

<template name="setupStepOne">
  {{#autoForm schema=schema doc=data id="setup-step-one-form"}}

    {{> afQuickField name="username"}}

    {{> afQuickField name="password"}}

    <button type="submit" class="btn btn-success btn-lg pull-right">Next</button>

  {{/autoForm}}
</template>

<template name="setupStepTwo">
  {{#autoForm schema=schema doc=data id="setup-step-two-form"}}

    {{> afQuickField name="confirm"}}

    <button type="submit" class="btn btn-success btn-lg pull-right">Submit</button>

  {{/autoForm}}
</template>


Then configure your schema's and steps

Template.setupWizard.steps = function() {
  return [{
    id: 'stepOne',
    title: 'Step 1. Your account',
    template: 'setupStepOne',
    formId: 'setup-step-one-form'
  }, {
    id: 'stepTwo',
    title: 'Step 2. Confirm',
    template: 'setupStepTwo',
    formId: 'setup-step-two-form',
    onSubmit: function(data, mergedData) {
      Accounts.createUser(mergedData, function(err) {
        if(!err) Router.go('/');
      });
    }
  }]
}

Template.setupStepOne.schema = function() {
  return new SimpleSchema({
    'username': {
      type: String,
      label: 'Username',
      min: 2,
      max: 30
    },
    'password': {
      type: String,
      label: 'Password',
      min: 6
    }
  });
}

Template.setupStepTwo.schema = function() {
  return new SimpleSchema({
    'password': {
      type: Boolean,
      label: 'Confirm your registration'
    }
  });
}
请检查下面添加的小程序。我认为这对你有帮助。 {{>wizard id=“安装向导”步骤=步骤} {{{#autoForm schema=schema doc=data id=“设置步骤一表单”} {{>afQuickField name=“username”} {{>afQuickField name=“password”} 下一个 {{/autoForm} {{{#autoForm schema=schema doc=data id=“setup step two form”} {{>afQuickField name=“confirm”} 提交 {{/autoForm} 然后配置您的模式和步骤 Template.setupWizard.steps=函数(){ 返回[{ id:'第一步', 标题:“步骤1.您的帐户”, 模板:“setupStepOne”, formId:“设置步骤一表单” }, { id:'第二步', 标题:“步骤2.确认”, 模板:“设置步骤二”, formId:“设置步骤二表单”, onSubmit:函数(数据、合并数据){ Accounts.createUser(合并数据,函数(err){ 如果(!err)Router.go('/'); }); } }] } Template.setupStepOne.schema=函数(){ 返回新的SimpleSchema({ “用户名”:{ 类型:字符串, 标签:“用户名”, 民:2,, 最多:30 }, “密码”:{ 类型:字符串, 标签:“密码”, 最小:6 } }); } Template.setupstep2.schema=函数(){ 返回新的SimpleSchema({ “密码”:{ 类型:布尔型, 标签:“确认您的注册” } }); }
更多详细信息或向我们展示您目前拥有的一些代码?因此,我将我的单个架构(在文档集合中)拆分为两个架构(相当于向导步骤),并尝试了您的建议,但不起作用。我也尝试了以下方法,但没有成功。Template.setupStepOne.helpers({schema:function(){return Documents.DocumentSchema1;}}});作为最后一步,我将simpleschema插入到文档中提到的模板中,它在这种情况下起作用。结论是向导包不支持集合中SimpleSchema的定义,但在模板帮助程序中需要它们。