这个作业属于哪个课程 https://edu.cnblogs.com/campus/sdscfz/SF4
这个作业要求在哪里 https://edu.cnblogs.com/campus/sdscfz/SF4/homework/12974
这个作业的目标 第11次作业-构造函数创建对象
<!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>
    <button onclick="stu1()">显示自我介绍</button>
    <script >
        function Stu(name, age, gender, hobby,time) {
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.hobby = hobby;
            this.time = time;
            this.stu2 = function() {
              document.write("大家好,我叫" + this.name + ",今年" + this.age + "岁,性别" + this.gender + ",我的爱好是" + this.hobby + "。" + "现在的时间是:" + this.time);
            }
           }
           var me = new Stu("刘牧豪", 19, "男", "唱跳rap篮球","2023年5月18号周四下午9点35分");
           function stu1() {
               me.stu2();
          }
    </script>
</body>
</html>


posted on 2023-05-18 21:40  刘牧豪  阅读(10)  评论(0编辑  收藏  举报