关于mootools中的bind的一个测试

来源:互联网 发布:日系小清新滤镜软件 编辑:程序博客网 时间:2024/06/05 14:05

 <script type="text/javascript" src="mt.js"></script>
<script type="text/javascript">

var demo = new Class({
    initialize: function(){
        document.write('justok');
    },
   
    nogo : function(){
        document.write('nogo');
    },

    come : function(ok){
        alert(ok);
        this.nogo();
        return
    },

    go : function(){
        var g = this.come.bind(this); // 试试此处不用bind(this),会有什么效果
        setTimeout(function(){g('justok')}, 2000);
    }

});

var test = new demo();
test.go();

</script>

原创粉丝点击