兼容IE浏览器对象不支持toBlob属性或方法问题

pull/176/MERGE
RuoYi 2020-07-13 12:47:47 +08:00
parent b09955f369
commit 7d1b67a8b7
1 changed files with 39 additions and 20 deletions

View File

@ -237,6 +237,25 @@ function submitHandler() {
$(window).resize(function() {
$('.imageBox').height($(window).height() - 80);
}).resize();
if (!HTMLCanvasElement.prototype.toBlob) {
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
value: function(callback, type, quality) {
var canvas = this;
setTimeout(function() {
var binStr = atob(canvas.toDataURL(type, quality).split(',')[1]);
var len = binStr.length;
var arr = new Uint8Array(len);
for (var i = 0; i < len; i++) {
arr[i] = binStr.charCodeAt(i);
}
callback(new Blob([arr], {
type: type || 'image/png'
}));
});
}
});
}
</script>
</body>
</html>