el-upload将文件转为Blob类型


参考了很多内容,这个最直接:

1、Vue

 <el-upload
    class="upload-demo upload-tip"
     drag
     ref="upload"
     :action="uploadUrl()"   
     :auto-upload="false"      
     :on-change="onUploadChange"
     multiple>
     <i class="el-icon-upload"></i>
     <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
     <div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过500kb</div>
 </el-upload>

2、JS

onUploadChange(file){
      const that = this
      const _file = file.raw;
      let blob = new Blob([_file], { type: "audio/wav"});
      console.log('blob:', blob);
}
Logo

前往低代码交流专区

更多推荐