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

测试测试一下

上级 eee01192
......@@ -63,24 +63,24 @@ export default {
},
// 显示裁剪框
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 = window.atob(canvas.toDataURL(type, quality).split(',')[1]);
// var len = binStr.length;
// var arr = new window.Uint8Array(len);
// for (var i = 0; i < len; i++) {
// arr[i] = binStr.charCodeAt(i);
// }
// // callback(new window.Blob([arr], { type: type || 'image/jpeg' }));
// callback(new window.Blob([arr], { type: type || 'image/jpeg' }));
// });
// }
// });
// }
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 = window.atob(canvas.toDataURL(type, quality).split(',')[1]);
var len = binStr.length;
var arr = new window.Uint8Array(len);
for (var i = 0; i < len; i++) {
arr[i] = binStr.charCodeAt(i);
}
// callback(new window.Blob([arr], { type: type || 'image/jpeg' }));
callback(new window.Blob([arr], { type: type || 'image/jpeg' }));
});
}
});
}
this.croppShow = true
this.cropper = new Cropper(this.$refs.canvas, {
......@@ -123,6 +123,8 @@ export default {
const cropParam = this.cropper.getData()
console.log('cropParam', cropParam);
this.cropper.getCroppedCanvas().toBlob(function (blob) {
var objecturl = window.URL.createObjectURL(blob);
console.log('objecturl', objecturl);
let files = new window.File([blob], 'cropper.jpg');
console.log('getCroppedCanvas', files);
let oFileReader = new window.FileReader()
......
......@@ -6,7 +6,7 @@ import store from './store/'
const mixins = require('@/utils/mixins');
import FastClick from 'fastclick'
import vueFilters from '@/utils/filter'
import '@/utils/toBlob';
// import '@/utils/toBlob';
// 引入ElementUI
import ElementUI from 'element-ui';
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册