// 数据流处理 let blobType = switchType(fileFmt); const blob = new Blob([result.data],{ type: blobType }); let blobURL= window.URL.createObjectURL(blob); window.open(blobURL,'_blank'); //判断类型的方法 function switchType(fileFmt) { let blobType = ''; switch (fileFmt) { case "html": blobType = "text/html"; break; case "docx": blobType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case "doc": blobType = "application/msword"; break; case "pdf": blobType = "application/pdf"; break; case "jpg": blobType = "image/jpeg"; break; case "png": blobType = "image/png"; break; case "xlsx": blobType ="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; case "txt": blobType = "text/plain;charset=utf-8"; break; } return blobType; }
标签:case,文件,fileFmt,blobType,处理,break,application,let From: https://www.cnblogs.com/star-meteor/p/18234618