uni.chooseImage({count: 1,sizeType: ['original', 'compressed'],sourceType: ['camera'], //这要注意,camera掉拍照,album是打开手机相册succ
uni.chooseImage({count: 1,sizeType: ['original', 'compressed'],sourceType: ['camera'], //这要注意,camera掉拍照,album是打开手机相册success(res) {const tempFilePaths = res.tempFilePaths;uni.uploadFile({url: 'https://pro.hxqygl.online/api/carno/status', //服务器地址fileType: "image", //ZFB必填,不然报错filePath: tempFilePaths[0], //这个就是我们上面拍照返回或者先中照片返回的数组name: 'img',success(uploadFileRes) {let imgData = JSON.parse(uploadFileRes.data)if(imgData.data == null){uni.showToast({title:'查询失败',icon:'error',duration:2000})}else{uni.showToast({title: `查询成功`,duration: 4000})}_this.chepai = imgData.data.car_no_this.number = imgData.data.num// console.log(this);// this.imgDataUrl = imgData.data.imgUrl}});}}); 需要注意的是我在代码片段中用到 _this,因为我怕函数改变了this的指向所有我在方法的开头就写了
let _this = this
来源地址:https://blog.csdn.net/m0_66809099/article/details/129836976
--结束END--
本文标题: uniapp在微信小程序端调用摄像头拍照并且把拍下的图片上传到后端
本文链接: https://www.lsjlt.com/news/441295.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0