本帖最后由 qq137337016 于 2011-07-29 12:33:41 编辑

解决方案 »

  1.   

    largeImage.prototype={
      getImage:function(imgElement,obj){
      var arr;
      var img = new Image();
      img.src=imgElement.src;
      if(img.complete){
      return function(){
      return function(){
      arr=new Array(img.width,img.height);
      }.call(obj)
      }
      }
      img.onload=function(){
      return function(){
      arr=new Array(img.width,img.height);
      }
      }.call(obj)
      },
      init:function(){
      var large = this.getImage(this.largeImage,this)();
      //这里要得到getImage返回的数组该怎么写?一直写不对额!
      }
    }
      

  2.   

    getImage()它就没返回数组嘛。返回的是个函数啊。。而且getImage()里,你把数组 复值给私有变量arr。。你是取不到它的值得。你得写个公开方法来取它吧
      

  3.   

    方法是我自己写的,可以改的
    largeImage.prototype={ 
      getImage:function loadImage(url, callback) {
        var img = new Image();     
         img.src = url;
       
        if (img.complete) {  
            callback.call(img);
            return;
        }    img.onload = function () { 
            callback.call(img);
        };
    },
       init:function(){
            var large = this.getImage(this.largeImage,this)();
      //方法是自己写的,可以改的。本来是那样的,只是我想callback.call(img);这个都替换成返回一个数组
       }
    }