格式1:
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TextInput,
} = ReactNative;
var navigator = Rect.createClass( {
render() {
return (
); }
});
import React from 'react';
import {
AppRegistry,
Text
} from 'react-native';
const App = React.createClass( {
return (
<Text>Hello World!</Text>
);
});
AppRegistry.registerComponent('MyApp', () => App);
import React, { Component, } from 'react';
import {
AppRegistry,
Image,
ListView,
StyleSheet,
Text,
View, } from 'react-native';
class SampleAppMovies extends Component {
render() {
return ( );
}
}
<View style = {[styles.flex]}>
</View>
onPress = {this.show.bind(this,this.props.news[i])}:bind方法第一个参数是上下文,第二个参数是需要传递的参数;
this.props:子组件调用父组件的属性
numberOfLine = {2} 最多显示两行
<Text
key = {i}
onPress = {this.show.bind(this,this.props.news[i])}
numberOfLine = {2}
style = {[styles.news_item]}>
{this.props.news[i]}
</Text>
show:function(title){
alert(title);
},
标签 | 作用 | 备注 |
---|---|---|
flex | 平铺整个屏幕 | |
borderWidth | 边框的宽度 | |
borderColor | 边框的颜色 | |
flexDirection | 布局方向(column,row) | 默认是纵向:column |
justifyContent | 沿主轴线的对齐方式 | flex-start,flex-end,center,space-between,space-around |
alignItems | 交叉轴上的对齐方式 | flex-start,flex-end,center,baseline,stretch |
marginTop | 与顶部的间距 | marginLeft,marginRight,marginBottom |
borderRadius | 设置圆角 | |
backgroundColor | 背景颜色 | #ff0067 |
borderLeftWidth | 边框左边宽度 | borderRightWidth,borderBottomWidth |
fontSize | 字体大小 | |
fontWeight | 字体宽度 | |
bold | 加粗 | |
alert(title) | 弹出提示框 |
2024 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123