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

测试测试一下

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