代碼直接用就可以了,當然請注意瀏覽器版本
//傳入file文件
getObjectURL(file) {
let url = null;
if (window.createObjcectURL != undefined) {
url = window.createOjcectURL(file);
}else if (window.URL != undefined) {
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) {
url = window.webkitURL.createObjectURL(file);
}
return url;
}