zoukankan      html  css  js  c++  java
  • 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)
        },
    
  • 相关阅读:
    js中的字符串
    JSOP
    jq总结1
    jq总结
    诗和远方-志
    诗和远方-感
    js判断变量是否为空字符串、null、undefined
    判断js对象是否为空
    诗和远方-悟
    深复制
  • 原文地址:https://www.cnblogs.com/justyouadmin/p/12691306.html
Copyright © 2011-2022 走看看