function test(){}
test.prototype = {
   temp:0,
   a:function(){
      temp++;
      window.setTimeout(this+".test()",30);
   }
}为什么这样不能循环调用?、要报错,在类的方法里面调用自己方法的正确语法是怎么写??,急急急~~~~~~!!!!!!!!

解决方案 »

  1.   

    setTimeout 第一个参数是函数的句柄 你那样写,算什么了?
      

  2.   

    1L说的对
    function Test(){
    this.temp = 0;
    }Test.prototype = {
    test: function(){
    alert(this.temp);
    },
    start: function(){
    this.temp++;
    var self = this;
    window.setTimeout(function(){
    self.test();
    }, 3000);
    }
    }
    var demo = new Test();
    demo.start();
      

  3.   


    function test(){} 
    test = { 
      temp:0, 
      a:function(){ 
          this.temp++; 
          alert(this.temp);
          window.setTimeout("test.a()",500); 
      } 

    test.a()
      

  4.   

    setTimeout("要运行的方法",要在多少毫秒后执行);
      

  5.   

       还不知道, 还没解决呢, 我也Fuck You!
     
       楼上的都是牛啊!