导致SimpleSchema的原因不是collections.js的构造函数错误

时间:2018-06-26 12:44:44

标签: javascript meteor simpl-schema

使用simpl-schema时出现以下错误:

SimpleSchema is not a constructor

我已经添加了

aldeed:autoform
aldeed:collection2@3.0.0
"simpl-schema": "^1.4.3"

我的代码:

import { Mongo } from 'meteor/mongo';    
import  SimpleSchema  from 'simpl-schema';     
export const Books = new Mongo.Collection("books");     
const Book = new SimpleSchema({
    title: {
        type: String,
        label: "Title",
        max: 200
    },
    author: {
        type: String,
        label: "Author"
    },
    copies: {
        type: SimpleSchema.Integer,
        label: "Number of copies",
        min: 0
    },
    lastCheckedOut: {
        type: Date,
        label: "Last date this book was checked out",
        optional: true
    },
    summary: {
        type: String,
        label: "Brief summary",
        optional: true,
        max: 1000,
        optional: true
    }
});
Books.attachSchema(Book);

是什么原因造成的,我该如何解决?

0 个答案:

没有答案