0
点赞
收藏
分享

微信扫一扫

vscode 关键字记录

进击的铁雾 04-13 12:00 阅读 2
<template>
	<view>
		<video id="video"></video>
	</view>
</template>	

摄像头显示在video标签上

var opts = {
	audio: false,
	video: true
}

navigator.mediaDevices.getUserMedia(opts).then((stream)=> {
	video = document.querySelector('video');
	video.srcObject = stream
	video.play();
}).catch((err)=>{
	console.log(err)
});

拍照 npm i html2canvas

cxBackToBlank() {
	uni.showLoading({});
	html2canvas(document.querySelector('video'), {
		backgroundColor: null,
		useCORS: true
	}).then(async (canvas) => {
		let url = canvas.toDataURL('image/jpeg');
	})
},
<style scoped>
	#video {
		position: absolute;
		left: 100rpx;
		top: 100rpx;
		width: 1000rpx;
		height: 1000rpx;
	}
</style>	

在这里插入图片描述
在这里插入图片描述

举报

相关推荐

0 条评论