私はExpo XDEをインストールし、新しいプロジェクトfunproject
を作成しました。私はXDEがデバイス用であり、仮想デバイスに接続できることを理解しています。WebアプリケーションでのReact-Nativeの使用
しかし、Webアプリケーションにも同じコードベースを再利用したいと思います。
私は自分のローカルホストのどこにアプリを置くべきかを知りました。
このように見えますが、index.htmlページが表示されます。それは実際のファイルパスです。
ここfunproject\node_modules\react-native\local-cli\server\middleware\index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>React Native</title>
</head>
<body>
<p>React Native packager is running.</p>
<p><a href="http://facebook.github.io/react-native/">Visit documentation</a></p>
</body>
</html>
の内容は、だから私は、コンテンツおよびスクリプトのdiv要素を追加し、
<!DOCTYPE html>
<html>
<head>
<title>React Native</title>
</head>
<div id="content"></div>
<body>
<p>React Native packager is running.</p>
<p><a href="http://facebook.github.io/react-native/">Visit documentation</a></p>
</body>
</html>
<script type="text/javascript" src="../app.js"></script>
私が反応するために新しいですがapp.jsが、私がウェブをターゲットにできるアイデア、そしてモバイルをすべて一つにするというアイデアは非常に魅力的です。残念ながら、これは動作しません!私はChromeデベロッパーツールを使用すると、私はここでapp.js
Uncaught SyntaxError: Unexpected token import app.js:1
のライン1のために、このエラーを取得しています。デフォルトはapp.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
なぜ誰かが、 –