谢谢你从现在开始的回答,

我是一个React Native岁的新手,我想做一个跨平台的应用程序,所以我创建了索引.js:

import React from 'react';
import {
    Component,
    View,
    Text,
} from 'react-native';

class ReactApp extends Component {

    render() {
        return (
            <View><Text>Hello world</Text></View>
        );
    }
}

module.exports = ReactApp;

然后我导入了索引.两个索引中的js.网间网操作系统.js和索引.安卓就像这样:

import { AppRegistry } from 'react-native';
import ReactApp from './index';

AppRegistry.registerComponent('ReactApp', () => ReactApp);

我想在这之后它应该会起作用,但我明白了

enter image description here

推荐答案

react 后v0.49,你不需要index.ios.jsindex.android.js.你只需要index.js:

import {AppRegistry} from 'react-native';
import App from './app/App';

AppRegistry.registerComponent('appMobile', () => App);

(将appMobile替换为应用程序的名称)

资料来源:(https://github.com/facebook/react-native/releases/tag/v0.49.0)

从现在起,新项目只有一个入口点(index.js)

React-native相关问答推荐

Redux将旧状态迁移到新状态

Touchabble 不透明度不工作-react 本机

react-native useEffect / useFocusEffect / useCallback 没有正确更新

TextInput 中的大写文本 - react native

如何停止在 textInput React Native 中输入空格?

如何在react-native 中从 FlatList 中删除元素/索引?

React Redux 使用带有连接组件的 HOC

如何在 mac 上卸载 react-native-cli?

react-native 中 android 和 iOS 的图像大小

如何在 React Navigation createStackNavigator 中更改字体系列

React Native:双击退出应用程序

Error when running watchman

无法在 react native >= 0.60 中链接assets(字体)

在特定屏幕上使用react-navigation修改后退按钮

HighLight / ScrollTo - React-Native 上的 ListView、ScrollView

带有父 PanResponder 的 TouchableOpacity

react-native:多色文本视图

React-native google 登录给开发人员错误

为什么我收到警告:函数作为 React 子级无效?

如何在 React Native 中强制禁用 iOS 暗模式