// 这里是导入的包 import React, { Component } from ‘react‘; // 导入需要用到的组件 import { AppRegistry, Text, View } from ‘react-native‘; // 定义一个类,在 render 回调中返回 Text 控件, class Greeting extends Component{ render(){ return( // 从调用标签中取出 props.name ,并将其插入到 文本中 <Text>你好,{this.props.name}!</Text> ); } } export default class AwesomeProject extends Component { render() { return( <View style={{alignItems:‘center‘,marginTop:50}}> <Greeting name=‘李荣浩‘ /> <Greeting name=‘李云龙‘ /> <Greeting name=‘李小璐‘ /> </View> ); } } AppRegistry.registerComponent(‘AwesomeProject‘, () => AwesomeProject);
时间: 2024-10-17 03:49:44