Commit b7be905b authored by hetech's avatar hetech Committed by GitHub

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

* Upload: create blob URL when picture displays

* Update index.vue
parent b8cdeceb
...@@ -146,12 +146,14 @@ export default { ...@@ -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 { ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment