为什么我得出图片的长宽都为null?
loadPicSize:function(sourceSrc){ console.log(sourceSrc); var self =this; this.preLoadImg(sourceSrc,function(){ self.popupPic.attr("src",sourceSrc); console.log("self.popupPic:"+self.popupPic); var picWidth =self.popupPic.width(); var picHeight=self.popupPic.height(); console.log("picWidth:"+picWidth); console.log("picHeight:"+picHeight); }); }, preLoadImg:function(src,callback){ var img=new Image(); if(!!window.ActiveXObject){ img.onreadystatechange=function(){ if (this.readyState=="complete") { callback(); }; }; }else { img.onload=function(){ callback(); }; }; img.src=src; },
代码如上,报错如下
这个问题卡了好久求解答!