“用户”不是类中的构造函数

编程入门 行业动态 更新时间:2024-10-08 00:31:18

“用户”不是类中的构造<a href=https://www.elefans.com/category/jswz/34/1771370.html style=函数"/>

“用户”不是类中的构造函数

当我在文件顶部声明它时,用户不是构造函数

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
    }
}

谢谢!

回答如下:

更多推荐

“用户”不是类中的构造函数

本文发布于:2024-05-30 06:48:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770220.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   类中   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!