如何使用相机电容器进行反应

问题描述 投票:0回答:1

我想通过在我的反应代码中插入电容式摄像机来打开我的电脑的摄像机,但失败。有我的代码:

import React, { useState } from 'react';
import { Plugins, CameraResultType } from '@capacitor/core';

const App = () => {

  const { Camera } = Plugins;

  const [photo, setPhoto] = useState();
  const takePhoto = async () => {
    console.log("Launch function");
    const image = await Camera.getPhoto({
      quality: 90,
      allowEditing: false,
      resultType: CameraResultType.Uri
    });
    console.log(image.webPath);
    setPhoto(image.webPath);
  };

  return (
    <div className="App">

      {photo ? <img src={photo} alt="test camera" /> : <span>There is no picture yet.</span>}

      <button onClick={takePhoto}>Camera</button>

    </div>
  );
}
export default App;

这是我得到的错误:that is my console screeshoot

reactjs ionic-framework camera capacitor
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.