学习React Native(三)HelloWorld 基本源码学习
如果有错误请大家在下面留言,没办法,谁让自己是小白,边查资料边学!请包涵! 'use strict';
js 严格模式
var {
AppRegistry,//AppRegistry 定义了App的入口,并提供了根组件
StyleSheet,//布局
Text,//显示文字的Text
View,//View 容器 Text载体
} = React;
声明的变量,在下文代码中都可以找到相应的方法 var HelloWorld = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
HelloWorld
</Text>
<Text style={styles.instructions}>
To get started,edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
});
如果没有查资料,单从表面看,应该是创建了一个类,来承载视图 var styles = StyleSheet.create({ container: { flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',},welcome: { fontSize: 20,textAlign: 'center',marginBottom: 0,instructions: { textAlign: 'center',color: '#333333',marginBottom: 5,});
这个是改变布局的样式 让我想起了ios Autlayout,如果你有开发经验应该能猜出来一些属性是干什么用的 上面写的就当我意淫了!看下面!看下面! 看下面! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |