如何修复 Meteor AutoForm datetimepicker 中的 'dtp.setDate' 错误?

How to fix 'dtp.setDate' error in Meteor AutoForm datetimepicker?

我正在尝试使用这个 AutoForm 包,但是当我尝试他们自己的代码时出现了这个错误。

TypeError: dtp.setDate is not a function
at null.<anonymous> (aldeed_autoform-bs-datetimepicker.js:141)
at view.js:199
at Function.Template._withTemplateInstanceFunc (template.js:457)
at view.js:197
at Object.Blaze._withCurrentView (view.js:538)
at viewAutorun (view.js:196)
at Tracker.Computation._compute (tracker.js:323)
at new Tracker.Computation (tracker.js:211)
at Object.Tracker.autorun (tracker.js:562)
at Blaze.View.autorun (view.js:209)

我有的是一个仅显示快速表单的模板:

<template name="test">
<h1>Autoform test</h1>
{{> quickForm collection="Tests" id="insertTest" type="insert"}}
</template>

还有一个简单的模式测试:

Tests = new Mongo.Collection("tests");

TestsSchema = new SimpleSchema({
  typeTest: {
    type: Date,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "bootstrap-datetimepicker"
      }
    }
  }
});

Tests.attachSchema(TestsSchema);

我已按照 this page 中给出的说明进行操作,并将 aldeed:autoform-bs-datetimepickertsega:bootstrap3-datetimepicker 添加到我的 Meteor 项目中。

这是 4.x.x 版本中的 known issue。您可以通过降级到版本 3.1 来修复此错误。3_3.

要安装版本为 3.1 的 tsega:bootstrap3-datetimepicker 包。3_3,运行 以下命令:

meteor add tsega:bootstrap3-datetimepicker@=3.1.3_3 

您可能还想安装 twbs:bootstrap 软件包以获得完整的 Bootstrap 支持。