为什么canvas.toDataURL获取图片是空白
时间:2020-07-23 21:33:18
收藏:0
阅读:585
第一种写法(错误):
var downLoadImgUrl = $("#QRCode-item canvas")[0].toDataURL("image/png");
第二种写法(正确):
var _fixType = function(type) { type = type.toLowerCase().replace(/jpg/i, ‘jpeg‘); var r = type.match(/png|jpeg|bmp|gif/)[0]; return ‘image/‘ + r; }; var type = ‘png‘; var fixType = _fixType(type); downLoadImgUrl = $("#QRCode-item canvas")[0].toDataURL(fixType); downLoadImgUrl = downLoadImgUrl.replace(fixType, ‘image/octet-stream‘);
以上两种写法生成的图片地址:
其他页面图片预览的src:
##################################################################################################################################################
参考博文链接:https://www.it1352.com/718250.html
参考博文素材:
原文:https://www.cnblogs.com/syjp/p/13367419.html
评论(0)