Upload: create blob URL when picture displays (#12402)

* Upload: create blob URL when picture displays

* Update index.vue
pull/12684/head
hetech 2018-09-10 10:59:55 +08:00 committed by GitHub
parent b8cdecebf7
commit b7be905b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -146,12 +146,14 @@ export default {
raw: rawFile raw: rawFile
}; };
if (this.listType === 'picture-card' || this.listType === 'picture') {
try { try {
file.url = URL.createObjectURL(rawFile); file.url = URL.createObjectURL(rawFile);
} catch (err) { } catch (err) {
console.error(err); console.error('[Element Error][Upload]', err);
return; return;
} }
}
this.uploadFiles.push(file); this.uploadFiles.push(file);
this.onChange(file, this.uploadFiles); this.onChange(file, this.uploadFiles);
@ -241,6 +243,14 @@ export default {
} }
}, },
beforeDestroy() {
this.uploadFiles.forEach(file => {
if (file.url && file.url.indexOf('blob:') === 0) {
URL.revokeObjectURL(file.url);
}
});
},
render(h) { render(h) {
let uploadList; let uploadList;