<template>
<div>
<video ref="video" autoplay></video>
</div>
</template>
<script>
export default {
mounted() {
this.startCamera();
},
methods: {
startCamera() {
navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => {
this.$refs.video.srcObject = stream;
})
.catch(error => {
console.log('Error accessing media devices.', error);
});
}
}
};
</script>
web调起摄像头
最新推荐文章于 2024-05-27 21:58:48 发布