npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cropper-image-taro-vue3

v1.0.9

Published

这是一个基于Taro的图片裁剪组件

Readme

cropper-image-taro-vue3 组件库

介绍

cropper-image-taro-vue3 是一个基于 Vue 3Taro 开发的裁剪工具组件,支持图片裁剪、裁剪框拖动、缩放和输出裁剪后的图片。该组件适用于 Vue 3 和 Taro 环境,可以在网页、小程序等平台中使用。

源码

https://gitee.com/xctf/cropper-image-taro-vue

安装

你可以通过 npmyarn 安装该组件库。

npm install cropper-image-taro-vue3
# 或者使用 yarn
yarn add cropper-image-taro-vue3

效果

效果

使用

你可以直接导入并使用 cropper-image-taro-vue3 组件。

1.组件导入与使用:

<template>
  <div>
    <cropper-image-taro-vue3 ref="cropperRef" :imagePath="imagePath" :debug="true" />
    <button @click="handleCrop">裁剪图片</button>
    <button @click="handleReInit">重置裁剪框</button>
  </div>
</template>

<script>
import { ref } from 'vue';
import { cropperImageTaroVue3 } from 'cropper-image-taro-vue3';  // 导入组件

export default {
  components: {
    cropperImageTaroVue3,  // 注册组件
  },
  setup() {
    const imagePath = ref('path_to_image.jpg');  // 图片路径
    const cropperRef = ref(null);  // 用于获取组件的引用

    const handleCrop = () => {
      // 通过 ref 调用组件的方法
      if (cropperRef.value) {
        cropperRef.value.crop();  // 调用 crop 方法进行裁剪
      }
    };

    const handleReInit = () => {
      // 通过 ref 调用组件的 reInit 方法重置裁剪框
      if (cropperRef.value) {
        cropperRef.value.reInit();  // 调用 reInit 方法
      }
    };

    return {
      imagePath,
      cropperRef,
      handleCrop,
      handleReInit,
    };
  },
};
</script>

2. 组件 Props

| Prop | 类型 | 说明 | 默认值 | |-----------------------|--------------------|-------------------------------------------------------------|----------| | imagePath | String | 图片路径 | 无 | | debug | Boolean | 是否开启调试模式,打印调试信息 | false | | minBoxWidthRatio | Number | 最小剪裁宽度比例(相对于原图宽度) | 0.15 | | minBoxHeightRatio | Number | 最小剪裁高度比例(相对于原图高度) | 0.15 | | initialBoxWidthRatio| Number | 裁剪框初始宽度比例 | 0.6 | | aspectRatio | Number \| null | 目标图片宽高比,如果设置,将限制裁剪框宽高比。 | null | | outputFileType | String | 输出文件类型,jpgpng | jpg | | quality | Number | 输出图片质量,范围从 0 到 1 | 1 |

3. 组件方法

组件暴露了两个主要方法:

  • crop:用于裁剪图片,调用后将返回裁剪后的文件路径。
  • reInit:重新初始化裁剪框。
可以使用ref获取组件实例操作裁剪组件

4. 组件事件

组件可以触发以下事件:

| 事件名 | 说明 | |----------------------|-------------------------------------------------------------| | ok | 裁剪完成后,返回裁剪后的图片路径。 |

<cropper-image-taro-vue3 :imagePath="imagePath" @ok="handleCropResult" />

<script>
export default {
  methods: {
    handleCropResult(filePath) {
      console.log('裁剪后的图片路径:', filePath);
    }
  }
};
</script>