我正在尝试需要一个脚本:
const { Search } = require('../models/Search')
作为回报,我在编辑器中给了我这个错误:
属性"搜索"在类型"搜索"上不存在。
当我执行代码时,我在控制台中收到此错误:
类型错误:搜索不是构造函数
型号/搜索.js
module.exports = class Search extends Model {
constructor() {
super()
// Set some property values here
}
}
我在这里错过了什么?
模块导出是类本身Search
,而不是将其作为Search
属性包含的对象。
它应该是:
module.exports = class Search extends Model {...}
和
const Search = require('../models/Search')
或:
exports.Search = class Search extends Model {...}
和
const { Search } = require('../models/Search')