javascript对象中this问题

来源:互联网 发布:方舟生存进化优化mod 编辑:程序博客网 时间:2024/06/11 05:51
<!DOCTYPE html><html><head>    <title>1111111</title>    <meta http-equiv="content-type" content="text/html;charset=utf-8" />    <style type="text/css">    body{    }    </style></head><body><script type="text/javascript">    var Obj = function(msg){    this.msg = msg;     this.shout = function(){        alert(this.msg);    }      this.waitAndShout = function(){        //隔五秒钟后执行上面的shout方法         var that =this;         setTimeout(function(){            that.shout();         },1000);    }}var aa = new Obj("aa");aa.waitAndShout();</script></body></html>
0 0
原创粉丝点击