swan.chooseImage
Object object
success返回参数说明 :
tempFiles 对象结构如下:
图片示例
代码示例1 - tempFilePaths :
- 在 js 文件中
- 在 js 文件中
Page({
chooseImage() {
swan.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
// 文件列表对象
console.log(res.tempFiles);
let imageList = [];
imageList.push(e.path)
})
this.setData('imageList', imageList);
fail: err => {
console.log('错误码:' + err.errCode);
console.log('错误信息:' + err.errMsg);
}
});
}
});
Android
iOS
- 文件的临时路径,在智能小程序本次启动期间可以正常使用,如需持久保存,需在主动调用 swan.saveFile,在智能小程序下次启动时才能访问得到。