photopicker
图片选择器
API
pick
pick(params, callback) since v28.0.2
@params
type {number}: 选择图片类型:0:拍摄选择照片1:从相册中选择base64 {boolean}: 是否返回图片的base64数据:true:代表返回false:代表不返回
@callback
result {string}: 结果三种类型success,cancel,errorfileName {string}: 文件名filePath {string}: 路径fileSize {number}: 文件大小(字节)mimeType {string}: 文件类型base64 {string}: 图片的base64数据,当params的base64为true时才有数据返回fileWidth {number}: 图片的宽fileHeight {number}: 图片的高
const photopicker = weex.requireModule('photopicker');
photopicker.pick({
type: 0,
base64: true
}, event => {
if (event.result == 'success') {
this.fileName = event.fileName;
this.filePath = event.filePath;
this.fileSize = event.fileSize;
this.mimeType = event.mimeType;
this.base64 = event.base64;
this.fileWidth = event.fileWidth;
this.fileHeight = event.fileHeight;
}
});