使用以下代码
const getCamera = () => {
navigator.mediaDevices
.getUserMedia({
audio: true,
video: { facingMode: { exact: "user" } },
})
.then((stream) => {
// 摄像头开启成功
console.log(videoRef);
videoRef.value.srcObject = stream;
videoRef.value.play();
})
.catch((err) => {
console.log(err);
});
}
ヾ( ̄▽ ̄)Bye~Bye~