wx-cropper
基于原生的微信小程序的裁剪组件
引入
支持npm包管理的模式项目目录下执行
npm i @dw/wx-cropper
也可以直接使用项目中的wx-cropper文件夹的文件,放到自己的项目中去
使用
在使用的页面的.json文件中注册
{
"usingComponents": {
"my-cropper": "@dw/wx-cropper"
}
}
注册之后在使用的wxml的文件中引入该组件
bind:close="hideCut"
cutRatio="{ {cutRatio}}"
wx:if="{ {showCropper}}"
imageSrc="{ {imageSrc}}"
cropperRatio={ {cropperRatio}}
cropperWidth={ {cropperWidth}}
minCropperW={ {minCropperW}}/>
参数配置
close: 事件 参数为img, 在点击关闭的时候没有这个参数,只有在生成图片的时候才有
path: string;
width: number;
height: number;
hideCut () {
this.setData({
<