UNIAPP |
您所在的位置:网站首页 › 手机拍照移动怎么拍的 › UNIAPP |
直接上代码: HTML: 创建事件 image uni.chooseImage() API 将上传或拍照的图片,打印res。 返回结果的tempFilePaths[0] 就是图片地址,但是这个地址不能直接用,可以放在新数组里面, 因为最多需要传9张,超出的pop掉最后一个就行,并且给用户提示最大数量 image(){ uni.chooseImage({ count:9, sizeType: ['original', 'compressed'], sourceType: ['album'], //这要注意,camera掉拍照,album是打开手机相册 success: (res)=> { // console.log(res); // const tempFilePaths = res.tempFilePaths; // this.zp = res.tempFilePaths[0]; // console.log(this.zp) this.list.push(res.tempFilePaths[0]) // console.log(this.list) } }); },data里面写个空数组 list:[ ] this.list.push(res.tempFilePaths[0]) 即可。 在页面上,需要放置图片的地方,遍历数组list,让item动态放到 :src下面 即可。 这样再设置图片的大小,就能按你需要方式放页面上。代码不全,只给思路。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |