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)
    },
posted @ 2020-04-13 14:44  清梦徐徐丶莫  阅读(11495)  评论(0编辑  收藏  举报