当前位置:网站首页>图片裁剪插件cropper.js
图片裁剪插件cropper.js
2022-07-02 05:51:00 【想吃凤梨酥】
安装
npm install cropperjs
引入
import 'cropperjs/dist/cropper.css';
import Cropper from 'cropperjs';
使用
const letImg: any = document.querySelector("#cropImg");
(<any>state.cropper) = new Cropper(letImg, {
viewMode: 1,
dragMode: "none",
initialAspectRatio: 1,
aspectRatio: 1,
preview: ".before",
background: false,
autoCropArea: 0.6,
zoomOnWheel: false,
crop: () => {
state.cropperImgBase64 = (<any>state.cropper)
.getCroppedCanvas()
.toDataURL("image/jpeg");
console.log(state.cropperImgBase64);
},
});
注意:
- 不能直接用本地图片
- 可以用上传预览的图片
边栏推荐
- 【LeetCode】Day92-盛最多水的容器
- PHP extensions
- 软件测试答疑篇
- Zzuli:1067 faulty odometer
- Technologists talk about open source: This is not just using love to generate electricity
- 3D printer G code command: complete list and tutorial
- PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
- RGB 无限立方体(高级版)
- 2022-2-15 learning xiangniuke project - Section 8 check login status
- Small and medium-sized projects to achieve certification and authorization of hand filter
猜你喜欢
2022-2-15 learning xiangniuke project - Section 8 check login status
centos8安装mysql8.0.22教程
Software testing Q & A
idea開發工具常用的插件合集匯總
2022-2-14 learning xiangniuke project - Section 6 displays login information
死磕大屏UI,FineReport开发日记
"Simple" infinite magic cube
Win10 copy files, save files... All need administrator permission, solution
Vscode paste image plugin saves image path settings
如何写出好代码 — 防御式编程指南
随机推荐
"Original, excellent and vulgar" in operation and maintenance work
Uva548 tree
Zzuli:1067 faulty odometer
With an amount of $50billion, amd completed the acquisition of Xilinx
460. LFU cache bidirectional linked list
2022-2-14 learning xiangniuke project - Section 7 account setting
Huawei Hongmeng OS, is it OK?
Addchild() and addattribute() functions in PHP
Zzuli:1068 binary number
js判断移动端还是pc端
460. LFU 缓存 双向链表
Zzuli:1064 encrypted characters
Simply encapsulate JS and apply it
Matplotlib double Y axis + adjust legend position
Applet jumps to official account
死磕大屏UI,FineReport开发日记
正则表达式总结
RGB 无限立方体(高级版)
运动健身的一些心得经验
数理统计与机器学习