首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

!对象为什么无法调用子函数

2013-06-25 
求救!对象为什么无法调用子函数代码如下(function(scope){var ImageCropper function(width, height, cr

求救!对象为什么无法调用子函数
代码如下


(function(scope){
var ImageCropper = function(width, height, cropWidth, cropHeight)
{
this.width = width;
this.height = height;
this.cropWidth = cropWidth;
this.cropHeight = cropHeight;

this.image = null;
this.imageCanvas = null;
this.imageContext = null;
this.imageScale = 1;
this.imageRotation = 0;

this.canvas = null;
this.context = null;
this.previews = [];
}

scope.ImageCropper = ImageCropper;

ImageCropper.prototype.loadImage = function(file)
{
alert("1");
var reader = new FileReader();
var me = this;
reader.readAsDataURL(file);
reader.onload = function(evt)
{
if(!me.image) me.image = new Image();
me.image.onload = function(e){me._init()};
me.image.src = evt.target.result;
}

}  })(window);


var cropper;
function init(){
cropper = new ImageCropper(300, 300, 180, 180);
}  
function onPhotoURISuccess(imageURI) {
cropper.loadImage(imageURI);
}

cropper是ImageCropper赋予的对象,我想通过cropper调用loadImage()函数但是无法成功这是为什么? 对象 函数 JavaScript
[解决办法]
代码没问题,请确定是否是先调用init方法,初始化cropper之后再调用onPhotoURISuccess

热点排行