【发布时间】:2020-03-03 10:22:56
【问题描述】:
我遇到了一个小问题,我希望有人能帮助我快速解决这个问题。这是我的代码:
class Client {
/**
* @param {ClientOptions} [options] Options for the client
*/
constructor(options = {}) {
super();
this.lnk = "https://marketpala.glitch.me";
this.endpoints = [
"/commandes.json",
"/users.json",
"/blacklist.json",
"/infov.json",
"/reserved.json"
]
}
}
这是导出客户端的代码:
module.exports = {
Client: require('./client/Client')
}
这是我用来测试我的客户的代码:
const tst = require('./palamazon')
let t = new tst.Client()
这是我得到的错误:
super();
^^^^^
SyntaxError: 'super' keyword unexpected here
希望有人可以帮助我!
(我正在用 javascript 编码)
【问题讨论】:
-
这能回答你的问题吗? super keyword unexpected here
-
在这种情况下为什么要调用 super()?
-
@KoroBaka 如果您正在学习某种教程并且它告诉您编写 super(),那么您很可能应该从某些东西扩展 Client。事实上,根据你使用类的方式(只是覆盖构造函数而不添加任何其他内容)我会说它甚至有可能。
标签: javascript keyword super