提交 cdf439c0 编写于 作者: guangjun.yang's avatar guangjun.yang

显示裁剪框

上级 3c32419a
...@@ -63,6 +63,24 @@ export default { ...@@ -63,6 +63,24 @@ export default {
}, },
// 显示裁剪框 // 显示裁剪框
initCropper () { initCropper () {
if (!HTMLCanvasElement.prototype.toBlob) {
console.log('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/jpeg' }));
});
}
});
}
this.croppShow = true this.croppShow = true
this.cropper = new Cropper(this.$refs.canvas, { this.cropper = new Cropper(this.$refs.canvas, {
checkCrossOrigin: true, checkCrossOrigin: true,
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册