vue获取图片宽高

 uploadFile(event){
        let that = this;
        let file = event.target.files[0];
        let fileReader = new FileReader();
        fileReader.readAsDataURL(file); //根据图片路径读取图片
        fileReader.onload = function(e) {
          let base64 = this.result;
          let img = new Image();
          img.src = base64;
          img.onload = function() {
            that.imgInfo = {
               img.naturalWidth,
              height: img.naturalHeight
            };
            console.log("宽:" + img.naturalWidth + " 高:" + img.naturalHeight);
          }
        }
      },
正道的光终将来临,当太阳升起的时候,光芒总会普照大地温暖人间。些许的阴霾也终会有被阳光洒满的一天
原文地址:https://www.cnblogs.com/sjruxe/p/14007265.html