wx.chooseImage({
count: 1,
sourceType: ['camera'],
success: (res) => {
this.setData({
ifphotosfzFront: false,
photosfzFront: res.tempImagePath,
});
console.log('照片路径:', res.tempImagePath);
},
fail: (err) => {
console.error(err);
},
});
上面是JS 下面HTML
<view class="left-section" bindtap="takesfzFront">
<image wx:if="{{ifphotosfzFront}}" class="section-image" src="/images/sfzFront.png" mode="" />
<image wx:else src="{{photosfzFront}}"></image>
<view>上传身份证正面</view>
</view>
https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html 从基础库 2.21.0 开始,本接口停止维护,请使用 wx.chooseMedia 代替