这ES6课程有什么意思? 200的X- 200旗新新200新新新200新新新200新新新200新新200新200新新200新新新200新新200新我该怎么用?
class polygon {
constructor(height,width) {
this.height = height;
this.width = width;
}
get area() {
return this.calcArea()
}
calcArea() {
return this.height * this.width;
}
}
这意味着该
功能是
属性的吸气剂.
要使用它,只要使用它的名称,就像你的任何其他属性:
'use strict'
class polygon {
constructor(height,width) {
this.height = height;
this.width = width;
}
get area() {
return this.calcArea()
}
calcArea() {
return this.height * this.width;
}
}
var p = new polygon(10,20);
alert(p.area);