-
This is a small program image clipping library *
-
小程序图片裁剪组件 *
"usingComponents": {
"tailor": "/components/tailor"
},
<tailor selWidth="420rpx" selHeight="500rpx" bindupload="myUpload" avatarSrc="{{img}}" avatarStyle="width: 210rpx; height: 250rpx;" id="tailor" noTab="true"></tailor>
myUpload(rep) {
this.setData({
img: rep.detail.path
})
},
selWidth,selHeight 可以设置裁剪框的尺寸
avatarStyle 设置裁剪的图片尺寸
noTab 是否显示裁剪操作按钮
avatarSrc 图片地址
注意:
组件使用了es6语法和vue的watch属性,需要引入两个库:runtime.js
miniprogrampatch.js:
引入后在app.js中注册
const regeneratorRuntime = require('/utils/runtime.js')
const { patchPage, patchComponent } = require('/utils/miniprogrampatch.js')
Page = patchPage(Page)
Component = patchComponent(Component)