函数"/>
“用户”不是类中的构造函数
当我在文件顶部声明它时,用户不是构造函数
const User = require('./User')
module.exports = class DmChannel {
/**
*
* @param {Client} client
* @param {*} data
*/
constructor(client, data) {
/**
* The client that instantiated this
* @name Base#client
* @type {Client}
* @readonly
*/
Object.defineProperty(this, 'client', { value: client })
this.id = data.id
this.last_message_id = data.last_message_id
this.type = data.type
this.name = data.name
this.flags = data.flags
this.createdTimestamp = Utils.getTimestampFrom(this.id)
this.createdAt = new Date(this.createdTimestamp)
this.user = data.user || data.recipients ? data.recipients.length < 1 ? null : new User(client, data.recipients[0]) : null
this.data_is_available = true
}
}
有人可以解释为什么“用户”不是构造函数被拒绝了吗? 这一个会起作用: 我需要在我需要的行上方的 User 类
module.exports = class DmChannel {
/**
*
* @param {Client} client
* @param {*} data
*/
constructor(client, data) {
/**
* The client that instantiated this
* @name Base#client
* @type {Client}
* @readonly
*/
Object.defineProperty(this, 'client', { value: client })
this.id = data.id
this.last_message_id = data.last_message_id
this.type = data.type
this.name = data.name
this.flags = data.flags
this.createdTimestamp = Utils.getTimestampFrom(this.id)
this.createdAt = new Date(this.createdTimestamp)
const User = require('./User')
this.user = data.user || data.recipients ? data.recipients.length < 1 ? null : new User(client, data.recipients[0]) : null
this.data_is_available = true
}
}
谢谢!
回答如下:更多推荐
“用户”不是类中的构造函数
发布评论