//原始创建类
function UIGoods(gd) {
  this.data = gd
  this.choose = 0
}

UIGoods.prototype.getTotalPrice = function () {
  return this.data.price * this.choose
}
const ui1 = new UIGoods({ price: 22 })
console.log(ui1.getTotalPrice())
//es6 创建类
class UIGood {
  constructor(gd) {
    this.data = gd
    this.choose = 0
  }
  getTotalPrice() {
    return this.data.price * this.choose
  }
}
const ui2 = new UIGood({ price: 22 })
console.log(ui2.getTotalPrice())