<script> class user{ constructor(name,age){ this.name=name; this.age=age; } showName(){ alert(this.name) } showAge(){ alert(this.age) } } var zhangsan=new user(‘aaaa‘,18); zhangsan.showName() zhangsan.showAge() </script>
原文:https://www.cnblogs.com/mrxinxin/p/10663478.html