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,11 +146,13 @@ export default {
raw: rawFile
};
try {
file.url = URL.createObjectURL(rawFile);
} catch (err) {
console.error(err);
return;
if (this.listType === 'picture-card' || this.listType === 'picture') {
try {
file.url = URL.createObjectURL(rawFile);
} catch (err) {
console.error('[Element Error][Upload]', err);
return;
}
}
this.uploadFiles.push(file);
@ -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) {
let uploadList;