当前位置:网站首页>图片裁剪插件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);
},
});
注意:
- 不能直接用本地图片
- 可以用上传预览的图片
边栏推荐
- Go language web development is very simple: use templates to separate views from logic
- OLED12864 液晶屏
- 1037 Magic Coupon
- 软件测试基础篇
- RGB 无限立方体(高级版)
- 1035 Password
- KMP idea and template code
- 记录sentry的踩坑之路
- php读文件(读取文件内含有某字符串的指定行)
- 2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
猜你喜欢

GRBL 软件:简单解释的基础知识

Software testing learning - day 4

2022-2-15 learning xiangniuke project - Section 8 check login status

Grbl software: basic knowledge of simple explanation

Win10 copy files, save files... All need administrator permission, solution

centos8安装mysql8.0.22教程

Fundamentals of software testing

【技术随记-08】

RGB 无限立方体(高级版)

Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
随机推荐
[leetcode] day92 container with the most water
Determine whether there is an element in the string type
生成二维码
1035 Password
Software testing learning - day 4
php继承(extends)
Youth training camp -- database operation project
vite如何兼容低版本浏览器
PHP extensions
File contains vulnerability (I)
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Reading notes of cgnf: conditional graph neural fields
brew install * 失败,解决方法
Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea
Practice C language advanced address book design
1037 Magic Coupon
php数组转化为xml
Get the details of the next largest number
数理统计与机器学习
Zzuli:1064 encrypted characters