自定义组件LoginView:
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class LoginView extends Component { render() { return ( <View style={styles.container}> <Text>aaa</Text> </View> ); } } const styles = StyleSheet.create({ container:{ flex:1, backgroundColor:'red', alignItems:'center', justifyContent:'center', }, }); // 输出,这里千万别忘记 module.exports = LoginView;
在index.ios.js文件中代码如图:
如上操作即可