<camera id=“myCamera” class=“camera” style=“display:{{cameraDisplay}};height:{{cameraHeight}}px” device-position=“back” flash=“auto” >
<cover-view class=“container” style=“height:{{cameraHeight}}px”>
<cover-view class=“pause” bindtap=“pause”>
<cover-image class=“img” src="…/…/images/icon.png" />
</cover-view>
</cover-view>
</camera>
const cameraContext = wx.createCameraContext(‘myCamera’);
Page({
data:{
cameraDisplay: ‘block’,
cameraHeight:1000,
},
pause:function(){
let that = this;
that.setData({
cameraDisplay: ‘none’,
cameraHeight:0,
});
cameraContext.takePhoto({
success: function (res) {
console.log(res);
},
})
})
只有camera中的cover-view cover-image 会被隐藏掉,但是camera还是显示的
<camera id=“myCamera” hidden=“hidden” class=“camera” style=“display:{{cameraDisplay}};height:{{cameraHeight}}px;visibility={{cameraHidden}}” device-position=“back” flash=“auto” >
<cover-view class=“container” style=“height:{{cameraHeight}}px;width:750rpx;”>
<cover-view class=“pause” bindtap=“pause”>
<cover-image class=“img” src="…/…/images/icon_pause.png" />
</cover-view>
</cover-view>
</camera>