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格式
  • 相关阅读:
    设计模式
    工厂方法模式
    简单工厂模式
    tornado自定义Form组件
    tornado
    Tornado框架的知识系列
    Linux基本命令
    day2
    day1
    使用cp复制文件夹却不能打开
  • 原文地址:https://www.cnblogs.com/dhjy123/p/14358879.html
Copyright © 2011-2022 走看看