1.安装包 npm install cropperjs
2.在使用的页面导入cropper js和css
import 'cropperjs/dist/cropper.css';
import Cropper from 'cropperjs';
3.基础配置,详细配置前往GitHub,
img标签要有一个容器包裹,img标签需要设置display: block;max-width: 100%;
const image = document.getElementById('image');
const cropper = new Cropper(image, {
viewMode: 1,
dragMode