我的是Vue项目
/**
- 从相册选择
*/
pictrueImg () {
let maxImgCount = 9 - this.imgList.length
mui("#picture").popover("hide")
plus.gallery.pick((e) => {
this.imgFileArray = e.files
this.compressImg(0)
}, (e) => {
mui.toast('取消选择图片')
}, {filter:"image",multiple:true,maximum:maxImgCount,system:false,onmaxed:() => {
plus.nativeUI.alert('最多只能选择' + maxImgCount + '张图片');
}
})
},
/**- 递归函数压缩图片
*/
compressImg (num) {
var imgFile = this.imgFileArray[num]
var name = imgFile.substr(imgFile.lastIndexOf('/') + 1)
plus.zip.compressImage({
src: imgFile,
dst: '_doc/' + name,
overwrite: true,
quality: 50
}, (zip) => {
this.imgList.push({
imgUrl: zip.target,
imgNumber: this.imgNumber ++
})
this.compressImg(num + 1)
}, (zipe) => {
mui.toast('压缩失败!')
})
},
- 递归函数压缩图片
0 个评论
要回复文章请先登录或注册