antd 上传图片获取宽高


   
    // 尺寸
    getFileWidthAndHeight (file) {
      const _URL = window.URL || window.webkitURL
      const img = new Image()
      img.onload = function () {
        console.log('width , height ', img.width, img.height)
      }
      img.src = _URL.createObjectURL(file)
    }
 
    handleBeforeUpload (file, fileList) {  // 上传回调
      return new Promise(async (resolve, reject) => {
        this.getFileWidthAndHeight(file)   //看这里
        console.log('handleBeforeUpload...', this.params, file)

        const imageReg = /\.(gif|jpg|jpeg|png|webp|GIF|JPG|JPEG|PNG|WEBP)$/
        if (imageReg.test(file.name)) {
          return this.GetUploadSinature(this.params).then(() => resolve())
        }
        const errText = '请选择图片上传'
        this.$message.error(errText)
        // eslint-disable-next-line prefer-promise-reject-errors
        reject()
      })
    },

// 待补充,实时获取的file格式

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM