4.9.93 • Published 3 months ago

bright-image-crop v4.9.93

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

antd-img-crop

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

npm npm npm bundle size GitHub npm type definitions

English | 简体中文

示例

Edit antd-img-crop

安装

yarn add antd-img-crop

# npm install antd-img-crop

使用

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

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

Props

属性类型默认说明
aspectnumber1 / 1裁切区域宽高比,width / height
shapestring'rect'裁切区域形状,'rect''round'
gridbooleanfalse显示裁切区域网格(九宫格)
qualitynumber0.4图片质量,0 ~ 1
fillColorstring'white'裁切图像小于画布时的填充颜色
zoombooleantrue启用图片缩放
rotatebooleanfalse启用图片旋转
minZoomnumber1最小缩放倍数
maxZoomnumber3最大缩放倍数
modalTitlestring'编辑图片'弹窗标题
modalWidthnumber | string520弹窗宽度,px 的数值或百分比
modalOkstring'确定'弹窗确定按钮文字
modalCancelstring'取消'弹窗取消按钮文字
onModalOKfunction-点击弹窗确定回调
onModalCancelfunction-点击弹窗遮罩层、右上角叉、取消的回调
beforeCropfunction-弹窗打开前调用,若返回 false,弹框将不会打开
onUploadFailfunction-上传失败时的回调
cropperPropsobject-react-easy-crop 的 props(* 已有 props 无法重写)

样式

为防止覆盖 antd 自定义样式,antd-img-crop 没有引入组件样式。

因此,若项目配置了 babel-plugin-import 且未使用 ModalSlider,请手动引入样式:

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

FAQ

ConfigProvider 未生效?

若使用 craco-antd,请在 craco.config.js 中添加 libraryDirectory: 'es'

module.exports = {
  plugins: [
    {
      plugin: CracoAntDesignPlugin,
      options: {
        // 其它配置...
+       babelPluginImportOptions: {
+         libraryDirectory: 'es',
+       },
      },
    },
  ],
};

若手动配置 babel-plugin-import,请在 .babelrc.js 中设置 libraryDirectory: 'es'

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

协议

MIT License (c) nanxiaobei

FUTAKE

试试 FUTAKE 小程序,你的灵感相册。🌈

FUTAKE

4.9.93

3 months ago

4.9.92

3 months ago

4.9.91

1 year ago

4.9.999

2 years ago

4.8.2

2 years ago

4.8.1

2 years ago

4.8.0

2 years ago