remove | 點擊移除文件時的回調,返回值為 false 時不移除。支持返回一個 Promise 對象,Promise 對象 resolve(false) 或 reject 時不移除。 | Function(file):?boolean | Promise | 無 |
beforeUpload | 上傳文件之前的鉤子,參數為上傳的文件,若返回?false ?則停止上傳。支持返回一個 Promise 對象,Promise 對象 reject 時則停止上傳,resolve 時開始上傳( resolve 傳入?File ?或?Blob ?對象則上傳 resolve 傳入對象)。注意:IE9 不支持該方法。 | (file, fileList) =>?boolean | Promise | 無 |
<a-upload multiple :remove="handleRemove" :beforeUpload="beforeUpload" :fileList="fileList"><a-button> 上傳文件</a-button>
</a-upload>
// 文件多選刪除文件操作handleRemove(file: FileInfo) {const index = this.fileList.indexOf(file);const newFileList = this.fileList.slice();newFileList.splice(index, 1);this.fileList = newFileList;},beforeUpload(file: FileInfo) {this.fileList = [...this.fileList, file];return false;},
?