/** * 首页的介绍,后面是平台,传入闭包 */ const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', });
type Props = {}; // App作为可导出的组件。创建一个名叫App的组件Component exportdefaultclassAppextendsComponent<Props> { render() { return ( <Viewstyle={styles.container}> <Textstyle={styles.welcome}>Welcome to React Native!</Text> <Textstyle={styles.instructions}>To get started, edit App.js</Text> <Textstyle={styles.instructions}>{instructions}</Text> </View> ); } }