React Native 入门
Helle World代码分析Helle World代码分析
import React,{ Component } from 'react';
import {
AppRegistry,StyleSheet,Text,View,} from 'react-native';
export default class HelloWorldAppp extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started,edit index.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'n'}
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',},welcome: {
fontSize: 20,textAlign: 'center',margin: 10,instructions: {
textAlign: 'center',color: '#333333',marginBottom: 5,});
AppRegistry.registerComponent('AwesomeProject',() => HelloWorldAppp);
初看这段代码,可能觉得并不像JavaScript——没错,这是“未来”的JavaScript. JSX调试代码中添加打印可以使用console.log(“”)方法,在logcat中过滤ReactNativeJS TAG。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |