此代码不提供镜像摄像头。我怎么能做到呢?
import React from "react";
import Webcam from "react-webcam";
class Component extends React.Component {
render() {
return <Webcam />;
}
}
有一个名为的属性mirror,这是一个布尔值,如果为真则镜像,否则不。
class Component extends React.Component {
render() {
return <Webcam mirrored={true} />;
}
}
对于前置摄像头,以下代码工作:
class Component extends React.Component {
render() {
const videoConstraints = {
facingMode: "user"
};
return <Webcam videoConstraints={videoConstraints} />;
}
}
后置摄像头:
class Component extends React.Component {
render() {
const videoConstraints = {
facingMode: { exact: "environment" }
};
return <Webcam videoConstraints={videoConstraints} />;
}
}
本页详情:链接