4.24.1 • Published 6 months ago

antd-img-crop-alt v4.24.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Link in bio to widgets, your online home screen. ➫ 🔗 kee.so


antd-img-crop

图片裁切工具,用于 Ant Design Upload 组件

npm npm npm bundle size GitHub npm type definitions

English | 简体中文

安装

pnpm add antd-img-crop
# or
yarn add antd-img-crop
# or
npm i antd-img-crop

使用

import { Upload } from 'antd';
import ImgCrop from 'antd-img-crop';

const Demo = () => (
  <ImgCrop>
    <Upload>+ Add image</Upload>
  </ImgCrop>
);

Edit antd-img-crop

Props

属性类型默认说明
qualitynumber0.4裁切图片质量,01 之间
fillColorstring'white'裁切图像填充色
zoomSliderbooleantrue允许缩放
rotationSliderbooleanfalse允许旋转
aspectSliderbooleanfalse允许调整裁切比
showResetbooleanfalse显示重置按钮,重置缩放 & 旋转 & 裁切比
resetTextstring重置重置按钮文字
aspectnumber1 / 1裁切区域宽高比,width / height
minZoomnumber1最小缩放
maxZoomnumber3最大缩放
minAspectnumber0.5最小裁切比
maxAspectnumber2最大裁切比
cropShapestring'rect'裁切区域形状,'rect''round'
showGridbooleanfalse显示裁切区域网格(九宫格)
cropperPropsobject-react-easy-crop 的 props(* 已有 props 无法重写)
modalClassNamestring''弹窗 className
modalTitlestring'编辑图片'弹窗标题
modalWidthnumber | string弹窗宽度
modalOkstring确定按钮文字
modalCancelstring取消按钮文字
onModalOKfunction-点击确定按钮的回调
onModalCancelfunction-点击取消按钮、遮罩层、或右上角 'x' 的回调
modalPropsobjectAnt Design Modal 的 props(* 已有 props 无法重写)
beforeCropfunction-裁切弹窗打开前的回调,若返回 falsereject,弹窗将不会打开

FAQ

ConfigProvider 无效?

尝试设置 libraryDirectory'es''lib')到 babel-plugin-import 的配置项,看看哪个会生效。

module.exports = {
  plugins: [
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
};

没有样式?(仅 antd<=v4

若使用 antd<=v4 + babel-plugin-import,且未引入 ModalSlider,请手动引入这些样式:

import 'antd/es/modal/style';
import 'antd/es/slider/style';

协议

MIT License (c) nanxiaobei

4.24.1

6 months ago

4.24.0

6 months ago