JavaScript-class继承

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Student{
            constructor(name){
                this.name = name;
            }

            hello(){
                alert('hello')
            }
        }
        var xiaoming = new Student("xiaoming");
    </script>

</body>
</html>


posted on 2022-05-13 21:33  言语说  阅读(27)  评论(0编辑  收藏  举报

导航