為什么輸出寬高為undefined呢
loadImage:function(sourceSrc){
? ?var self=this;
? ?//判斷圖片是否加載完畢
? ?this.preLoadImage(sourceSrc,function(){
? ? ? ?console.log(self.picImage.attr("src"))
? ? ? ?self.picImage.attr("src",sourceSrc);
? ? ? ?var imageWidth=self.picImage.width(),
? ? ? ? ? ?imageHeight=self.picImage.height();
? ? ? ?console.log(imageWidth+","+imageHeight);
? ?});
},
preLoadImage:function(src,callback){
? ?var img=new Image();
? ?if(!!window.ActiveXObject){
? ? ? ?//ie瀏覽器判斷預(yù)加載
? ? ? ?img.onreadystatechange=function(){
? ? ? ? ? ?if(this.readyState=="complete"){
? ? ? ? ? ? ? ?callback();
? ? ? ? ? ?}
? ? ? ?};
? ?}
? ?else{
? ? ? ?img.onload=function(){
? ? ? ? ? ?callback();
? ? ? ?}
? ?}
? ?img.src=src;
},
2018-02-23
檢查一下picImage有沒有問題
2022-03-30