Iron Router路由入口数据检索功能运行两次

Iron Router routing entry data retrieval function run twice

我是 Meteor 的新手(以及与此相关的全栈 JS 开发),正在尝试转换我目前在 Google App Engine 上 运行 的应用程序在 Django/Python.

我有以下使用 Iron Router 的路由条目:

this.route("editFacility", {
  path: "/facilities/:_id/edit",
  template: "editFacility",
  data: function() {
    return Facilities.findOne({ _id: this.params._id });
  }
});

...和以下模板(使用自动表单的快速表单):

<template name="editFacility">
  <h2>Edit facility "{{description}}"</h2>
  <div class="row">
    <div class="col-md-12">
      {{> quickForm
        collection="Facilities"
        omitFields="createdAt, updatedAt"
        doc=this
        id="updateFacilityForm"
        type="update"
        template="bootstrap3-horizontal"
        label-class="col-sm-2"
        input-col-class="col-sm-6"}}
    </div>
  </div>
</template>

路由被触发:

{{#linkTo route='editFacility' _id=this._id class="btn btn-default btn-xs"}}Edit{{/linkTo}}

最初看起来表单没有填充数据,但是在路由的data: 函数中放置debugger 语句显示该函数实际上是运行 两次。第一次找到文件并正确填写表格,紧随其后的是第二次,但没有找到,因此清除了表格。堆栈没有显示任何细节,并且两次运行看起来相同:

我用谷歌搜索了这个问题并找到了一些参考资料,但 none 找到了一个明确的解决方案。我已经将 meteor 和我所有的包裹更新到最新和最好的,但这个问题仍然存在。

所以我的问题是,是什么导致 meteor / Iron Router 执行此路由条目两次?

您的包裹列表中似乎缺少包裹 autopublish。它负责发布服务器中可用的所有数据。否则你需要写一个发布,然后在客户端订阅它。