Javascript 如何在App.js类react native中设置rootview
需要将登录页面设置为我的根视图和使用的代码。如果我使用app.js文件中的登录页面详细信息获取结果,但尝试在app.js文件中导入login.js,则无法工作Javascript 如何在App.js类react native中设置rootview,javascript,ios,reactjs,react-native,Javascript,Ios,Reactjs,React Native,需要将登录页面设置为我的根视图和使用的代码。如果我使用app.js文件中的登录页面详细信息获取结果,但尝试在app.js文件中导入login.js,则无法工作 import React, {Component} from 'react'; import { StyleSheet, NavigatorIOS,} from 'react-native'; import LoginPage from './src/pages/Login'; type Props = {}; expor
import React, {Component} from 'react';
import { StyleSheet,
NavigatorIOS,} from 'react-native';
import LoginPage from './src/pages/Login';
type Props = {};
export default class App extends Component<{}> {
render() {
return (
<NavigatorIOS
// style={styles.container}
initialRoute={{
title: 'Login',
component: LoginPage,
}}/>
);
}
}
在我的login.js类中
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
export default class Login extends Component {
render() {
return (
<View>
<Text style={styles.red}>Login</Text>
</View>
);
}
}
const styles = StyleSheet.create({
bigblue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});
// skip this line if using Create React Native App
AppRegistry.registerComponent('Demo', () => Login);
但是它没有将登录页面显示为rootview我在下面的问题中有一个例外的答案
它上面有一个谷歌驱动链接,你可以从那里下载一个示例项目,这是一个简单的应用程序。从示例应用程序中找出你应该如何设置app.js
我建议您应该使用StackNavigator进行导航。在我的应用程序中,遵循的最佳方法是使用StackNavigator配置app.js。能否显示index.js文件AppRegistry通常在index.js文件中设置