.clearFiles()constfile = files[0]asUploadRawFilefile.uid=genFileId() uploadRef.value!.handleStart(file)submitUpload() }constsubmitUpload= () => { uploadRef.value!.submit() }
el upload组件 第二次上传请求无效,非clearFiles方法 开发时遇到一个业务需求: 导入时如果当前列表月份存在数据将会提示用户是否要覆盖当前数据,点击确定进行二次提交 直接调用 submit 会无响应 this.$confirm(`${response.msg},是否继续?`,'提示', {confirmButtonText: 确定,cancelButtonText: 取消,type:'warning'}...
console.log('此时change了所有文件 开始上传',this.upFileList)this.submitUpload() },// 正式上传掉后端接口submitUpload () {if(this.upFileList.length >) {this.showPercent =truethis.fileNum = new FormData()// new formData对象this.fileNum.append('file',this.upFileList[])// append增加数据this....
// 只有执行这个的时候才会执行上面的提交 handleSubmit() { this.$refs.upload.submit() } handleChange(file, filelist) { if(filelist.length > 1) filelist.splice(0, 1) } // 注意事项: 1. 因为使用的:auto-uoload="false", 所以 before-upload 无效 2. 只能上传一个文件, 不能添加limit 1, 否...
{ accept }}</template>的文件</el-upload><el-buttontype="primary"@click="submitFile":disabled="butDis">确定</el-button><el-button@click="closeFileUpload">取消</el-button></el-dialog></template>import { getToken } from "@/utils/auth"; export default { name: "FileUpload", props:...
在组件设置:auto-upload="false"、ref="upload"、:http-request="handleUpload"之后,执行this.$refs.upload.submit(),便会触发http-request钩子。如果我们在http-request函数中发起上传请求,则仍是fileList有几个文件就调用几次接口,依旧无法实现在一次请求中上传多个文件。例子如下: ...
<el-row> <el-button type="primary" icon="el-icon-check"@click="uploadSucess('addForm')">提交</el-button> <el-button type="danger" icon="el-icon-circle-close"@click="cancleUpload">取消</el-button> </el-row> </el-form> </el-dialog> ...
target; }); return target; }, abort(file) { this.$refs['upload-inner'].abort(file); }, clearFiles() { this.uploadFiles = []; }, submit() { this.uploadFiles .filter(file => file.status === 'ready') .forEach(file => { this.$refs['upload-inner'].upload(file.raw); }); ...
:http-request="uploadFile"覆盖默认的上传行为,可以自定义上传的实现(this.$refs.upload1.submit() 会触发调用uploadFile函数) --> <el-upload ref="upload1"class="upload-demo"action="/chc-shop/api/v1/accident/szcp/electronicfile/upload"accept=".pdf":disabled="disabledUpload":auto-upload="false":...