我希望能够使用对象的成员变量:
function Upload(file, filename, id){
this.file=file
this.filename=filename
this.id=id;
};
Upload.prototype.displayImage = function(btn){
$.canvasResize(file,
{
width: 160,
height: 0,
crop: false,
quality: 100,
callback: function (data)
{
$('#'+btn).css("background", "url("+data+")")
}
});
};
我像这样访问对象和方法:
var upload = new Upload(frontPic, frontPicName, id);
upload.displayImage("btnFrontUploadShow");
但是我收到错误:
ReferenceError: file is not defined
$.canvasResize(file,
为什么不能file
在 displayImage 方法中使用变量,如何声明 displayImage 使file
变量可以使用?