文档地址:https://fengyuanchen.github.io/cropperjs/
使用方式:
.1 下载包
yarn add cropperjs
.2 导入包
importCropperfrom"cropperjs"
import"cropperjs/dist/cropper.css"
.3 自定义裁剪比例
const sizeList = [
{
name: "1:1",
size: 1 / 1,
},
{
name: "16:9",
size: 16 / 9,
},
{
name: "4:3",
size: 4 / 3,
},
{
name: "2:3",
size: 2 / 3,
},
{
name: "自由尺寸",
size: NaN,
},
]
.4 准备 state 数据
constructor(props) {
super(props)
this.imgRef = React.createRef()
this.state = {
buttonLoading: false,
currenIndex: 0,
}
}
.5 准备 html 结构
render() {
const { meCropShow, imgUrl } = this.props
const { buttonLoading, currenIndex } = this.state
return (
<Modal
className&#