微信小程序拍照并显示图片:详细步骤和代码示例
"takePhoto: function() {\n var that = this;\n wx.chooseMedia()({\n count: 3,\n mediaType: ['image'],//选择的图片尺寸 原图,压缩图\n sizeType: ['original'],//选择的图片尺寸 原图,压缩图\n sourceType: ['camera'],//相册选图,相机拍照\n success: function(res) {\n var tempImagePath = res.tempFilePaths[0];\n // 将图片路径添加到images数组中\n var images = that.data.images;\n images.push(tempImagePath);\n that.setData({\n images: images\n });\n }\n })\n} \n"要将图片显示在页面上,需要在wxml文件中添加一个image标签,并绑定图片路径。\n\n首先,在wxml文件中找到要显示图片的位置,添加以下代码:\n\n
原文地址: https://www.cveoy.top/t/topic/pwrA 著作权归作者所有。请勿转载和采集!