小程序
小游戏
企业微信
微信支付
扫描小程序码分享
- 当前 Bug 的表现(可附上截图)
ios调用此组件和API时出现短暂白屏
- 预期表现
5 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
代码片段不可用
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
贴这里可以吧。
wxml:
<view>
<camera wx:if="{{imgList.length<3}}" device-position="front" flash="auto" binderror="error" style="width: {{cameraWidth?cameraWidth:'100%'}}; height: {{cameraHeight?cameraHeight+'rpx':'750rpx'}};">
<cover-image class='pro' style="height:{{cameraHeight?(cameraHeight-100) + 'rpx':''}};width:{{cameraHeight?(cameraHeight-100) + 'rpx':''}};margin-left:{{cameraHeight?(-cameraHeight+100)/2 + 'rpx':''}}" src='../../images/people.png'></cover-image>
</camera>
<button wx:if="{{imgList.length<3}}" class='btn btn_bg' style='background-color:{{btnColor?btnColor:""}}' bindtap="takePhoto">{{btnText?btnText:'拍照'}}</button>
<view wx:if="{{imgList && imgList.length>1}}" class='preview'>预览</view>
<view class='imgbox'>
<block wx:for="{{imgList}}" wx:key="item">
<image mode="widthFix" src="{{item}}" class='' data-index="{{index}}" bindtap="deleteThis"></image>
</block>
</view>
<view class='flex'>
<button wx:if="{{imgList.length>=3}}" class='btn btn_bg btns' style='background-color:{{btnColor?btnColor:""}}' bindtap="next">下一步</button>
<button wx:if="{{imgList.length>=3}}" class='btn btn_bd btns' bindtap="clear">全部重新录入</button>
wxss:
.flex{
display: flex;
}
.flex_j_c{
justify-content: center;
.flex_a_c{
align-items: center;
.pro{
position: absolute;
top: 100rpx;
height: 550rpx;
/* width: 550rpx; */
z-index: 1000;
left: 50%;
.btn{
border-radius: 0;
border: 1rpx solid transparent;
.btns{
margin: 0 10rpx;
width: 50%;
.btn_bg{
background-color: #679af2;
color: #fff;
.btn_bd{
color: #679af2;
background-color: #fff;
border: 1rpx #679af2 solid;
.small-btn{
margin: 0 35rpx;
box-sizing: border-box;
.preview{
font-size: 28rpx;
padding: 15rpx;
.imgbox{
flex-wrap: wrap;
width: 100%;
margin: 1rpx;
.imgbox image{
margin: 1rpx 0;
padding: 0 1rpx;
width: 33.33%;
height: 250rpx;
button{
button:after{
border: none;
js:
takePhoto: function() {
// console.log('123');
var that = this;
const ctx = wx.createCameraContext();
var imgList = this.data.imgList;
if (imgList.length <= 2) {
if (imgList.length == 3) {
// that.triggerEvent('myTap', {
// imgList
// });
ctx.takePhoto({
quality: 'high',
success: (res) => {
if (imgList && imgList.length > 0) {
imgList.push(res.tempImagePath);
} else {
imgList = [res.tempImagePath]
this.setData({
imgList: imgList
})
}else{
console.log('最多三张');
},
error: function(e) {
console.log(e.detail)
clear: function(){
imgList: []
deleteThis: function(data){
wx.showModal({
title: '提示',
content: '确认重拍该张照片?',
success: function(res){
console.log(res,res.confirm);
if (res.confirm){
console.log(res.confirm, data.currentTarget.dataset);
that.data.imgList.splice(data.currentTarget.dataset.index,1);
that.setData({
imgList: that.data.imgList
next: function(){
this.triggerEvent('next', {
imgList:that.data.imgList
});
把flash改成off就不会了
谢谢了,我一直不知道这个前置的(没有闪光灯)打开会这个样子,感谢!
我这边也有这个问题 加了flash="off" 也没有解决 请问楼主解决了吗
camera hidden 切换有时候无法显示就白屏了
IOS白屏必现,我们家测试非要说是我调用的闪光灯,相信你能复现的。期待你的回复。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
代码片段不可用
贴这里可以吧。
wxml:
<view>
<camera wx:if="{{imgList.length<3}}" device-position="front" flash="auto" binderror="error" style="width: {{cameraWidth?cameraWidth:'100%'}}; height: {{cameraHeight?cameraHeight+'rpx':'750rpx'}};">
<cover-image class='pro' style="height:{{cameraHeight?(cameraHeight-100) + 'rpx':''}};width:{{cameraHeight?(cameraHeight-100) + 'rpx':''}};margin-left:{{cameraHeight?(-cameraHeight+100)/2 + 'rpx':''}}" src='../../images/people.png'></cover-image>
</camera>
<button wx:if="{{imgList.length<3}}" class='btn btn_bg' style='background-color:{{btnColor?btnColor:""}}' bindtap="takePhoto">{{btnText?btnText:'拍照'}}</button>
<view wx:if="{{imgList && imgList.length>1}}" class='preview'>预览</view>
<view class='imgbox'>
<block wx:for="{{imgList}}" wx:key="item">
<image mode="widthFix" src="{{item}}" class='' data-index="{{index}}" bindtap="deleteThis"></image>
</block>
</view>
<view class='flex'>
<button wx:if="{{imgList.length>=3}}" class='btn btn_bg btns' style='background-color:{{btnColor?btnColor:""}}' bindtap="next">下一步</button>
<button wx:if="{{imgList.length>=3}}" class='btn btn_bd btns' bindtap="clear">全部重新录入</button>
</view>
</view>
wxss:
.flex{
display: flex;
}
.flex_j_c{
justify-content: center;
}
.flex_a_c{
align-items: center;
}
.pro{
position: absolute;
top: 100rpx;
height: 550rpx;
/* width: 550rpx; */
z-index: 1000;
left: 50%;
}
.btn{
border-radius: 0;
border: 1rpx solid transparent;
}
.btns{
margin: 0 10rpx;
width: 50%;
}
.btn_bg{
background-color: #679af2;
color: #fff;
}
.btn_bd{
color: #679af2;
background-color: #fff;
border: 1rpx #679af2 solid;
}
.small-btn{
width: 50%;
margin: 0 35rpx;
box-sizing: border-box;
}
.preview{
font-size: 28rpx;
padding: 15rpx;
}
.imgbox{
display: flex;
flex-wrap: wrap;
width: 100%;
box-sizing: border-box;
margin: 1rpx;
}
.imgbox image{
margin: 1rpx 0;
padding: 0 1rpx;
width: 33.33%;
height: 250rpx;
box-sizing: border-box;
}
button{
border-radius: 0;
}
button:after{
border: none;
}
js:
takePhoto: function() {
// console.log('123');
var that = this;
const ctx = wx.createCameraContext();
var imgList = this.data.imgList;
if (imgList.length <= 2) {
if (imgList.length == 3) {
// that.triggerEvent('myTap', {
// imgList
// });
}
ctx.takePhoto({
quality: 'high',
success: (res) => {
if (imgList && imgList.length > 0) {
imgList.push(res.tempImagePath);
} else {
imgList = [res.tempImagePath]
}
this.setData({
imgList: imgList
})
}
})
}else{
console.log('最多三张');
}
},
error: function(e) {
console.log(e.detail)
},
clear: function(){
this.setData({
imgList: []
})
},
deleteThis: function(data){
var that = this;
wx.showModal({
title: '提示',
content: '确认重拍该张照片?',
success: function(res){
console.log(res,res.confirm);
if (res.confirm){
console.log(res.confirm, data.currentTarget.dataset);
that.data.imgList.splice(data.currentTarget.dataset.index,1);
that.setData({
imgList: that.data.imgList
})
}else{
}
},
})
},
next: function(){
var that = this;
this.triggerEvent('next', {
imgList:that.data.imgList
});
}
把flash改成off就不会了
谢谢了,我一直不知道这个前置的(没有闪光灯)打开会这个样子,感谢!
我这边也有这个问题 加了flash="off" 也没有解决 请问楼主解决了吗
camera hidden 切换有时候无法显示就白屏了
IOS白屏必现,我们家测试非要说是我调用的闪光灯,相信你能复现的。期待你的回复。