-
选择头像
function chooseAvatar(){ return new Promise((resolve, reject) => { uni.chooseImage({ count: 1, //默认9 sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], //从相册选择 camera 从相机上传 默认二者都有 success: function (res) { resolve(res.tempFilePaths[0]) } }) }) }
-
选择图片
function chooseAvatar(){ return new Promise((resolve, reject) => { uni.chooseImage({ count: 6, //默认9 sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], //从相册选择 camera 从相机上传 默认二者都有 success: function (res) { resolve(res.tempFilePaths) } }) }) }
-
选择视频
uni.chooseVideo({ sourceType:['album'], // 默认为:['album', 'camera'] 即相册和相机 count: 1, maxDuration: 60, // 视频最大时长限制 可修改小一点 success:function(res){ if(res.tempFilePath.startsWith("file:///")){ _this.videoPath = res.tempFilePath; }else{ _this.videoPath ="file:///" + res.tempFilePath; } } })
使用UNIAPP开发APP教程-02使用uniapp上传头像,照片及视频
最新推荐文章于 2025-04-17 10:39:38 发布