2017-08-25 16 views
0

我正在構建PhoneGap混合應用程序,其中包含使用cordova攝像頭插件的反應js和react-router。我使用PhoneGap開發人員應用程序在iPhone上測試應用程序。問題在於相機不會顯示在按鈕上。任何幫助將不勝感激。下面是攝像頭組件代碼:運行在瀏覽器中的應用程序,然後採取建立使用NPM運行構建Cordova攝像頭插件無法在反應js組件中工作

import React from 'react'; 
import '../css/poc-form.css'; 
import '../css/POCButton.css'; 

class Camera extends React.Component { 
    constructor(props) { 
     super(props); 
     this.state = { 
     value: '' }; 

     this.takePicture = this.takePicture.bind(this); 
    } 

takePicture(event) { 
     alert('take a picture'); 
     navigator.camera.getPicture(onSuccess, onFail, { 
     quality: 50, 
     destinationType: Camera.DestinationType.DATA_URL, 
     sourceType: Camera.SourceType.CAMERA 
    }); 

    function onSuccess(imageData) { 
     var image = document.getElementById('myImage'); 
     image.src = "data:image/jpeg;base64," + imageData; 
    } 

    function onFail(message) { 
     alert('Failed because: ' + message); 
    } 
    event.preventDefault(); 
} 


render() { 
     return (
     <div> 
      <link rel="stylesheet" type="text/css" href="poc.css"/> 
     <h1>Client ID Scanner</h1> 
      <button id = "takePicture" className = "POCButton" onClick={this.takePicture} >Take Picture</button> 
      <img id = "myImage" ></img> 
     </div> 
    ); 
    } 
    } 
    export default Camera; 

回答

0

1.一旦 - -p在反應項目,一旦其get完成了建造,請複製www文件夾在你的反應項目

2.done你在Xcode科爾多瓦創建示例應用程序下面的 https://cordova.apache.org/docs/en/latest/guide/cli/

三曾任只是這臺相機的插件添加到項目中 科爾多瓦插件添加科爾多瓦 - 插件相機 https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/

  • 然後分階段地科爾多瓦的應用程序的文件夾,請粘貼在科爾多瓦項目中的以下文件夾WWW
  • 5.then最後運行的iPod科爾多瓦項目或idevices.it將work.hope它可以幫助你

    相關問題