Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica.cloud.web-education-admin
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
提交
打开侧边栏
com.pica.cloud.education.frontend
pica.cloud.web-education-admin
提交
89fc80bb
提交
89fc80bb
编写于
6月 29, 2020
作者:
guangjun.yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
测试测试一下
上级
eee01192
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
19 行删除
+21
-19
cropper-img.vue
src/components/common/cropper-img.vue
+20
-18
main.js
src/main.js
+1
-1
未找到文件。
src/components/common/cropper-img.vue
浏览文件 @
89fc80bb
...
...
@@ -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
()
...
...
src/main.js
浏览文件 @
89fc80bb
...
...
@@ -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
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录