【发布时间】:2017-12-01 21:19:41
【问题描述】:
感谢您从现在开始的回答,
我是 React Native 的新手,我想做一个跨平台的应用,所以我创建了 index.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;
然后我像这样从 index.ios.js 和 index.android.js 导入 index.js:
import { AppRegistry } from 'react-native';
import ReactApp from './index';
AppRegistry.registerComponent('ReactApp', () => ReactApp);
我认为在此之后它应该可以工作,但我明白了 错误:
【问题讨论】:
-
请重命名索引文件并重试
-
您的图像不工作。此外,您没有说明您这样做是为了达到什么目的。
-
@MichaelCheng 图像工作我想因为我也在我的手机上试过,我想做一个跨平台的应用程序
-
@ravi.p 怎么样?为什么?
-
用这个替换 index.js 中的第一行并尝试 import React, {Component} from 'react';
标签: javascript android ios react-native cross-platform