突然发现,IOS可以长按保存图片,安卓有些不可以,怎么回事呢?图片明明正常显示的啊,原来是因为我这边图片文件是一个流,所以img标签配置的src对应url返回的content-type为application/octet-string ,尽然不是image/png这些玩意,所以识别不了是图片,好,那我直接转成base64吧。
function chooseStaticImg(imageUrl) {let th = this;this.getImageFileFromUrl(imageUrl, seq_no, function(file) {let reader = new FileReader();reader.onloadend = function() {th.base64 = reader.result;console.log(th.base64)};reader.readAsDataURL(file);});}// 根据路径返回filefunction getImageFileFromUrl(url, imageName, callback) {fetch(url).then((res) => {return res.blob();}).then((blob) => {let imgFile = new File([blob], imageName, { type: typeImg});callback(imgFile);});}
