`takePhoto: function() {\n var that = this;\n wx.chooseMedia({\n count: 3,\n mediaType: ['image'],\n sourceType: ['camera'],\n success: function(res) {\n var tempFilePaths = res.tempFiles.map(function(file) {\n return file.tempFilePath;\n });\n // 加入图片路径到 images 数组中\n var images = that.data.images;\n images.push(...tempFilePaths);\n that.setData({\n images: images\n });\n }\n });\n},\n\n<view class="photo-list">\n <block wx:for="{{images}}" wx:key="index">\n <image class="photo" src="{{item}}" mode="aspectFill"></image>\n <button class="delete-btn" data-index="{{index}}" bindtap="deleteImage" type="primary" size="mini">删除</button>\n </block>\n</view>`

微信小程序使用 wx.chooseMedia 拍摄三张图片并显示

原文地址: https://www.cveoy.top/t/topic/pwBA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录