<script> // 静态方法 class Person { constructor (name, age) { this.name = name; this.age = age; } sayHi () { console.log(hi,my name is </font><font style="color:#569cd6;">${</font><font style="color:#569cd6;">this</font><font style="color:#d4d4d4;">.</font><font style="color:#9cdcfe;">name</font><font style="color:#569cd6;">}</font><font style="color:#ce9178;">) } static create (name,age) { console.log(this) 不是指向实例对象,而是指向类型整体 return new Person(name,age) } } const p1 = Person.create(“zs”,19) console.log(p1)

    </script>静态成员 - 图1