【发布时间】:2020-04-27 12:06:10
【问题描述】:
我创建了一个 JavaScript class,如下所示:
class contact{
constructeur(nom,prenom){
this.nom = nom;
this.prenom = prenom;
}
function afficher(){
return "Nom : " + this.nom + "Prenom : " + this.prenom;
}
...
但我在 jslint Excepted an identifier saw 'class' 中有错误
而在 eslint 中,the keyword 'Class' is reserved 出现错误
【问题讨论】:
-
函数应该在类中吗?
-
你是否在 ESLint 中启用了 ES6 语法?应该有一个选项
ecmaVersion -
类的构造函数也应该用英文拼写,而不是外语。
-
是的,我已经在工具栏中设置了 ecmaVersion 选项
-
@Addis 是的
标签: javascript class eslint jslint