this.$message.warning(`You can upload up to 3 files. You selected ${files.length} files this time, and ${files.length + fileList.length} files totally`);
},
handleBeforeRemove(file, fileList) {
return new Promise((resolve, reject) => {
if (confirm('It looks good, are you sure to remove?')) {
resolve()
} else {
reject()
}
});
}
}
}
...
...
@@ -126,13 +135,14 @@ Upload files by clicking or drag-and-drop
### Click to upload files
:::demo Customize upload button type and text using `slot`. Set `limit` and `on-exceed` to limit the maximum number of uploads allowed and specify method when the limit is exceeded.
:::demo Customize upload button type and text using `slot`. Set `limit` and `on-exceed` to limit the maximum number of uploads allowed and specify method when the limit is exceeded. Set `before-remove` is able to abort the remove operation.
@@ -156,6 +166,15 @@ Upload files by clicking or drag-and-drop
},
handleExceed(files,fileList){
this.$message.warning(`The limit is 3, you selected ${files.length} files this time, add up to ${files.length+fileList.length} totally`);
},
handleBeforeRemove(file,fileList){
returnnewPromise((resolve,reject)=>{
if(confirm('It looks good, are you sure to remove?')){
resolve()
}else{
reject()
}
});
}
}
}
...
...
@@ -410,6 +429,7 @@ on-error | hook function when some errors occurs | function(err, file, fileList)
on-progress | hook function when some progress occurs | function(event, file, fileList) | — | — |
on-change | hook function when select file or upload file success or upload file fail | function(file, fileList) | — | — |
before-upload | hook function before uploading with the file to be uploaded as its parameter. If `false` is returned or a `Promise` is returned and then is rejected, uploading will be aborted | function(file) | — | —
before-remove | hook function before removing a file with the file and file list as its parameters. If `false` is returned or a `Promise` is returned and then is rejected, remove will be aborted. | function(file, fileList) | — | — |