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, error
    • fileName {string}: 文件名
    • filePath {string}: 路径
    • fileSize {number}: 文件大小(字节)
    • mimeType {string}: 文件类型
    • base64 {string}: 图片的base64数据,当params的base64true时才有数据返回
    • 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;
	}
});