我在识别javascript上的类时遇到了一个问题
我创建了一个JavaScript我在识别javascript上的类时遇到了一个问题,javascript,class,eslint,jslint,Javascript,Class,Eslint,Jslint,我创建了一个JavaScript类,如下所示: class contact{ constructeur(nom,prenom){ this.nom = nom; this.prenom = prenom; } function afficher(){ return "Nom : " + this.nom + "Prenom : " + this.prenom; } ... 但是我在jslint中有一个错误,除了一个标识符saw
类
,如下所示:
class contact{
constructeur(nom,prenom){
this.nom = nom;
this.prenom = prenom;
}
function afficher(){
return "Nom : " + this.nom + "Prenom : " + this.prenom;
}
...
但是我在jslint中有一个错误,除了一个标识符saw'class'
在eslint中,在
上给出了一个错误,关键字“Class”是保留的
您的代码有一些问题:
构造函数
拼写错误function
关键字函数是否应该在类中?是否在ESLint中启用了ES6语法?应该有一个选项
ecmaVersion
类的构造函数也应该用英语拼写,而不是外语。是的,我有,我已经有了选项ecmaVersiontoolbar@Addis是的
/*jshint esversion:6 */
class Contact {
constructor (nom, prenom) {
this.nom = nom;
this.prenom = prenom;
}
afficher () {
return "Nom : " + this.nom + " Prenom : " + this.prenom;
}
}