私は2つの仕事をすることが分かっており、同じものを探している他の人のためにここに投稿します。これを行うための他の方法があるかもしれませんが、これが私にとってうまくいきました。
だから、基本的に我々は(と言う)を使用して、コルドバのAppを作成します。
testappとフォルダ内の今
testapp
--hooks
--platforms
--plugins
--www
--config.xml
: コルドバは、これがそうと私のフォルダ構造を与えるtestappとのcom.test.testappのtestappと を作成私たちが実行する:create-react-app teastappReact testappフォルダの中に私の反応アプリを追加します。 あなたの反応アプリのメインのindex.jsは/ srcディレクトリにあります。
I index.jsは、関数内で自分のメインロジックをラップして、そのようなコルドバのオブジェクトと一緒に関数を呼び出してください:
今、あなたのアプリが一緒にコルドバのインスタンスを持つことになります行う必要があります
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
const startApp =() => {
ReactDOM.render(
<App />,
document.getElementById('root')
);
}
if(!window.cordova) {
startApp()
} else {
document.addEventListener('deviceready', startApp, false)
}
あなたのアプリ内にnavigator.cameraのようなDeviceオブジェクトがあります。
パブリックフォルダにあるindex.htmlの反応アプリでも、Codovaのwwwフォルダにあるindex.htmlのhtmlをコピーします。これで、wwwフォルダからすべてのファイルを削除できます。私たちは後で手作業で、または反応アプリのビルドフォルダからCordova wwwフォルダにすべてのファイルをコピーしてスクリプトを使ってコピーします。
私のindex.htmlは以下のようになります。codeova.jsファイルがスクリプトに含まれています。
アプリpackage.jsonは、次の行を追加し反応における最後
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<!--
Customize this policy to fit your own app's needs. For more guidance, see:
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
Some notes:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src * data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!-- Latest compiled and minified CSS -->
<title>React App</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="cordova.js"></script>
</body>
</html>
: を.... 『ホームページ』:「../www」 .... これはあなたの最終ビルドを確認しますファイルが正しいパスを指しています。 package.jsonビルドスクリプトに次の行を追加することもできます。
"scripts": {
"start": "react-scripts start",
***"build": "react-scripts build && robocopy .\\build ..\\www /MIR",***
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "npm run build&&gh-pages -d build"
}
これは、OS(Windowsの/ Linuxのなど)に基づいてrobocopyをまたはCP-Rすることができ..
私たちは、コルドバのアプリケーションを cordora build android/iosでビルドする準備ができているはずです。
私は2つの作業を行う方法を理解しており、同じ回答を探している他の人のためにここに投稿します。それはかなり些細で、おそらく他の方法がありますが、これは私にとってかなりうまくwprkedです。 –