element-ui upload组件 on-change事件 传自定义参数


<el-upload
    class="upload-demo"
    list-type="picture"
    accept="image/*"
    :show-file-list="false"
    :multiple="false"
    :auto-upload="false"
    action="https://jsonplaceholder.typicode.com/posts/"
    :on-change="(file, fileList) => {handleChange(file, fileList, name)}"
    :on-preview="handlePreview">
</el-upload>
    // 上传文件
    handleChangeFile(file, fileList, name) {
      const isLt10M = file.size / 1024 / 1024 < 10
      if (!this.$checkFileType(file.raw.name, ['png', 'jpg', 'jpeg'])) {
        this.$message.error('只能上传png、jpg、jpeg格式文件!')
        return false
      } else if (!isLt10M) {
        this.$message.error('上传文件大小不能超过 10MB!')
        return false
      }
      // let formdata = new FormData()
      // formdata.append('templateFile', file.raw)
      this.postData[name] = file.raw
      console.log(this.postData)
    },


免责声明!

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



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