uni.chooseInage(OBJECT) 从本地相册选择图片或使用相机拍照
count Numeber 否 对多可以选择的照片张数,默认9。
sizeType StringArray 否 original 原图,compressed 压缩图,默认二者都有。
sourceType StringArray 否 album从相册选图,camera使用相机,默认二者都有。
source Function 否 成功则返回图片的本地文件路径列表 temFilePaths。
fail Function 否 接口调用失败的回调函数。
complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行)。
<template> <View> {{name}}---{{age}} <button @click="img">选择照片</button> </View> </template> <script> export default { data(){ return{ age:'', name:'' } }, onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数 console.log(option.age); //打印出上个页面传递的参数。 console.log(option.name); //打印出上个页面传递的参数。 this.age=option.age; this.name=option.name; }, methods:{ img:function(){ uni.chooseImage({ count: 3, sizeType:"compressed", success: (res) => { console.log(res); uni.previewImage({ urls: res.tempFilePaths }) } }) } } } </script> <style> </style>