对不起,如果是重复的,但我没有找到解释。 如何在js类中创建字段?以定义未来...如何在javascript类中访问字段
class Polygon {
//var whyNot; This makes false
constructor(height, width) {
this.height = height;
this.width = width;
}
calcArea() {
return this.height * this.width;
}
}
? – War10ck
我不这么认为 - 我在这里找到了这个例子https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes,我试图学习清晰的文档。 – nolbadi111
这个例子是ES6。我已将标签添加到您的问题中,以提高其可见度。 – War10ck