@ballcat/vue-cropper

中文文档
1.0.6发布于 2023/11/08MITTypeScriptESM + CJS近 30 天下载 5547

vue image cropper by cropperjs

原始使用文档
文档目录8 节
  1. Demo
  2. Getting started
  3. Installation
  4. Usage
  5. API
  6. custom options
  7. Cropperjs options
  8. custom expose method

vue-cropper

A Vue image cropper components by cropperjs.

Github: https://github.com/ballcat-projects/vue-cropper

Demo

online demo: https://ballcat-projects.github.io/vue-cropper

You can also clone the repository and run the demo locally:

# clone
git clone https://github.com/ballcat-projects/vue-cropper.git

# enter the folder
cd vue-cropper/example

# install dependency
npm install

# run it
npm run dev

Getting started

Installation

npm install @ballcat/vue-cropper

or

yarn add @ballcat/vue-cropper

Usage

Global Registration

import { createApp } from 'vue';
import App from './App';

import VueCropper from '@ballcat/vue-cropper';
import 'cropperjs/dist/cropper.css';

const app = createApp(App);

app.use(VueCropper).mount('#app');

Local Registration

<template>
  <vue-cropper 
      ref="vueCropperRef"
      :src="imgSrc"
      alt="Source Image"
  />
</template>
<script>
import {ref, onMounted} from 'vue'
import VueCropper from '@ballcat/vue-cropper';
import 'cropperjs/dist/cropper.css';

export default {
  components: {
    VueCropper,
  },
  setup() {
    const imgSrc = ref('the image path')
    const vueCropperRef = ref(null);

    onMounted(() => {
      console.log(vueCropperRef.value.getData());
    });

    return {
      imgSrc,
      vueCropperRef
    };
  }
};
</script>

or use setup script

<script setup>
import {ref, onMounted} from 'vue'
import VueCropper from '@ballcat/vue-cropper';
import 'cropperjs/dist/cropper.css';

const imgSrc = ref('the image path')
const vueCropperRef = ref(null);

onMounted(() => {
  console.log(vueCropperRef.value.getData());
});
</script>

API

VueCropper props that can be used are divided into two parts, custom and all properties supported by cropperjs

custom options

PropertyDescriptionTypeRequired
srcorigin image srcstringtrue
imgStylethe img element styleobject--
imgCrossOriginthe img element crossOrigin attribute valuestring--
altthe img element alt attribute valueboolean--

Cropperjs options

see cropperjs document

custom expose method

MethodDescriptionType
flipXflip the picture horizontally() => void
flipYflip the picture vertically() => void

版本与发布记录

@ballcat/vue-cropper 共发布 6 个版本,首次发布于 2022/06/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.6latest2023/11/082 年前
1.0.52022/12/193 年前
1.0.42022/06/214 年前
1.0.32022/06/174 年前
1.0.22022/06/174 年前
1.0.12022/06/174 年前

关于 @ballcat/vue-cropper 的常见问题

@ballcat/vue-cropper 是什么?

vue image cropper by cropperjs

如何安装 @ballcat/vue-cropper?

在项目目录运行 npm install @ballcat/vue-cropper,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(>=3.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ballcat/vue-cropper 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ballcat/vue-cropper 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ballcat/vue-cropper 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ballcat/vue-cropper 可以商用吗?

@ballcat/vue-cropper 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ballcat/vue-cropper 的下载量有多少?

根据 npm 官方下载统计,@ballcat/vue-cropper 在 2026/10/08 – 2026/11/06 这 30 天内被下载 5,547 次,日均约 185 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ballcat/vue-cropper 还在维护吗?

最新版本 1.0.6 发布于 2023/11/08(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。