class Person {
      // 公有属性
      name;
      // 私有属性
      #age;
      #weight;
      // 构造方法
      constructor(name,age,weight){
            this.name = name;
            this.#age = age;
            this.#weight = weight;
      }
      
      intro(){
            console.log(this.name);
            console.log(this.#age);
            console.log(this.#weight);
      }
}
const girl = new Person('晓红',18, '45kg');
girl.intro()

相关文章:

  • 2021-11-09
  • 2021-05-23
  • 2021-08-12
  • 2021-08-17
  • 2021-08-17
  • 2021-10-31
  • 2021-10-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-07-27
  • 2022-02-24
相关资源
相似解决方案