react或vue直接打开摄像机

const inputRef = useRef<any>()
  
const handleCapture = () => {
    if (inputRef.current) {
      inputRef.current.click()
    }
  }

const handleInputChange = (event) => {
    const files = event.target.files[0]
    // 处理文件
    insertService.insertImage(files)
  }
 <input
   accept="image/*"
   capture={true}
   onChange={handleInputChange}
   ref={inputRef}
   style={{ display: 'none' }}
   type="file"
 />     

你可能感兴趣的:(vue.js,react.js,javascript)