zoukankan      html  css  js  c++  java
  • 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格式
  • 相关阅读:
    jqGrid jqGrid 参数
    jqgrid问题总结
    quartz的配置表达式
    Struts2接收参数的几种方式
    Perl爬虫代码
    PHP官方的PECL扩展有问题
    Perl单URL爬虫
    Perl 多进程进度条
    Perl Tk摸索
    hdu 2058 数学题
  • 原文地址:https://www.cnblogs.com/dhjy123/p/14358879.html
Copyright © 2011-2022 走看看