非常教程

React native参考手册

APIs

Layout Props

道具

alignContent?: enum('flex-start', 'flex-end', 'center', 'stretch', 'space-between', 'space-around')

alignContent控制行如何在横向上对齐,覆盖alignContent父项。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/align-content。

alignItems?: enum('flex-start', 'flex-end', 'center', 'stretch', 'baseline')

alignItems沿着横向方向对齐儿童。例如,如果孩子垂直流动,alignItems控制他们水平对齐的方式。它像align-itemsCSS 一样工作(默认:拉伸)。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/align-items。

alignSelf?: enum('auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline')

alignSelf控制孩子如何在横向排列,覆盖alignItems父母。它像align-selfCSS 一样工作(默认:auto)。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/align-self。

aspectRatio?: number

纵横比控制节点的未定义维度的大小。长宽比是一个非标准属性,只有在反应本机而不是CSS中才可用。

  • 在具有设置的宽度/高度宽高比的节点上控制未设置尺寸的尺寸
  • 如果未设置,则在设置了柔性基础高宽比的节点上控制交叉轴上节点的大小
  • 在具有度量函数纵横比的节点上,就好像度量函数测量弹性基础一样
  • 在具有弯曲增长/收缩纵横比的节点上,如果未设置,则控制交叉轴上节点的大小
  • 纵横比考虑最小/最大尺寸

borderBottomWidth?: number

borderBottomWidthborder-bottom-widthCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-width。

borderLeftWidth?: number

borderLeftWidthborder-left-widthCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-width。

borderRightWidth?: number

borderRightWidthborder-right-widthCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-width。

borderTopWidth?: number

borderTopWidthborder-top-widthCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-width。

borderWidth?: number

borderWidthborder-widthCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/border-width。

bottom?: number, string

bottom 是抵消此组件底部边缘的逻辑像素数。

它的工作方式与bottomCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关bottom如何影响布局的更多详细信息,请参见https://developer.mozilla.org/en-US/docs/Web/CSS/bottom。

display?: enum('none', 'flex')

display 设置此组件的显示类型。

它与displayCSS 类似,但只支持'flex'和'none'。'flex'是默认值。

flex?: number

在React中,Native flex不能像在CSS中那样工作。flex是一个数字而不是一个字符串,它可以根据https://github.com/facebook/yoga上的Yoga库来工作

何时flex是一个正数,它使组件变得灵活,并且它的大小将与其弹性值成比例。因此,flex设置为2 的组件将占用两倍的空间作为flex设置为1 的组件。

flex为0时,该组件是按照尺寸widthheight,它是不灵活的。

flex为-1时,组件通常按照widthheight。但是,如果没有足够的空间,组件会缩小到minWidthminHeight

flexGrow,flexShrink和flexBasis的工作方式与CSS中相同。

flexBasis?: number, string

flexDirection?: enum('row', 'row-reverse', 'column', 'column-reverse')

flexDirection控制容器的儿童的方向。row从左到右,column从上到下,你可能会猜到其他两个人做了什么。它像flex-directionCSS 一样工作,除了默认值是column。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction。

flexGrow?: number

flexShrink?: number

flexWrap?: enum('wrap', 'nowrap')

flexWrap控制儿童在弹性容器的末端是否可以环绕。它像flex-wrapCSS 一样工作(默认:nowrap)。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap。

height?: number, string

height 设置此组件的高度。

它的工作方式与heightCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/height。

justifyContent?: enum('flex-start', 'flex-end', 'center', 'space-between', 'space-around')

justifyContent使主要方向的儿童一致。例如,如果孩子垂直流动,justifyContent控制他们如何垂直对齐。它像justify-contentCSS 一样工作(默认:flex-start)。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content。

left?: number, string

left 是偏移此组件左边缘的逻辑像素数。

它的工作方式与leftCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关如何影响布局的更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/leftleft

margin?: number, string

设置margin有作为设置每个相同的效果marginTopmarginLeftmarginBottom,和marginRight。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/margin。

marginBottom?: number, string

marginBottommargin-bottomCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom。

marginHorizontal?: number, string

设置marginHorizontal有作为设置都相同的效果marginLeftmarginRight

marginLeft?: number, string

marginLeftmargin-leftCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left。

marginRight?: number, string

marginRightmargin-rightCSS 一样工作。有关更多详细信息,请参见https://developer.mozilla.org/en-US/docs/Web/CSS/margin-right。

marginTop?: number, string

marginTopmargin-topCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top。

marginVertical?: number, string

设置marginVertical有作为设置都相同的效果marginTopmarginBottom

maxHeight?: number, string

maxHeight 是此组件的最大高度,以逻辑像素为单位。

它的工作方式与max-heightCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关更多详细信息,请参见https://developer.mozilla.org/en-US/docs/Web/CSS/max-height。

maxWidth?: number, string

maxWidth 是此组件的最大宽度,以逻辑像素为单位。

它的工作方式与max-widthCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/max-width。

minHeight?: number, string

minHeight 是此组件的最小高度,以逻辑像素为单位。

它的工作方式与min-heightCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/min-height。

minWidth?: number, string

minWidth 是此组件的最小宽度,以逻辑像素为单位。

它的工作方式与min-widthCSS 类似,但在React Native中,您必须使用点数或百分比。Ems和其他单位不受支持。

有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/min-width。

overflow?: enum('visible', 'hidden', 'scroll')

overflow控制儿童如何测量和显示。overflow: hidden导致视图被裁剪,同时overflow: scroll导致独立于父母主轴的视图被测量。它像overflowCSS 一样工作(默认:可见)。有关更多详细信息,请参阅https://developer.mozilla.org/en/docs/Web/CSS/overflow。overflow: visible只适用于iOS。在Android上,所有视图都会剪辑他们的孩子。

padding?: number, string

设置padding有作为设置每个相同的效果paddingToppaddingBottompaddingLeft,和paddingRight。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding。

paddingBottom?: number, string

paddingBottompadding-bottomCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom。

paddingHorizontal?: number, string

设置paddingHorizontal就像设置paddingLeftpaddingRight

paddingLeft?: number, string

paddingLeftpadding-leftCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding-left。

paddingRight?: number, string

paddingRightpadding-rightCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding-right。

paddingTop?: number, string

paddingToppadding-topCSS 一样工作。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top。

paddingVertical?: number, string

设置paddingVertical就像设置paddingToppaddingBottom

position?: enum('absolute', 'relative')

position in React Native is similar to regular CSS, but everything is set to relative by default, so absolute positioning is always just relative to the parent.

If you want to position a child using specific numbers of logical pixels relative to its parent, set the child to have absolute position.

If you want to position a child relative to something that is not its parent, just don't use styles for that. Use the component tree.

See https://github.com/facebook/yoga for more details on how position differs between React Native and CSS.

right?: number, string

right is the number of logical pixels to offset the right edge of this component.

It works similarly to right in CSS, but in React Native you must use points or percentages. Ems and other units are not supported.

See https://developer.mozilla.org/en-US/docs/Web/CSS/right for more details of how right affects layout.

top?: number, string

top is the number of logical pixels to offset the top edge of this component.

It works similarly to top in CSS, but in React Native you must use points or percentages. Ems and other units are not supported.

See https://developer.mozilla.org/en-US/docs/Web/CSS/top for more details of how top affects layout.

width?: number, string

width sets the width of this component.

It works similarly to width in CSS, but in React Native you must use points or percentages. Ems and other units are not supported. See https://developer.mozilla.org/en-US/docs/Web/CSS/width for more details.

zIndex?: number

zIndex controls which components display on top of others. Normally, you don't use zIndex. Components render according to their order in the document tree, so later components draw over earlier ones. zIndex may be useful if you have animations or custom modal interfaces where you don't want this behavior.

It works like the CSS z-index property - components with a larger zIndex will render on top. Think of the z-direction like it's pointing from the phone into your eyeball. See https://developer.mozilla.org/en-US/docs/Web/CSS/z-index for more details.

iosdirection?: enum('inherit', 'ltr', 'rtl')

direction specifies the directional flow of the user interface. The default is inherit, except for root node which will have value based on the current locale. See https://facebook.github.io/yoga/docs/rtl/ for more details.

 © 2015–2017 Facebook Inc.

Licensed under the Creative Commons Attribution 4.0 International Public License.

https://facebook.github.io/react-native/docs/layout-props.html

React native

React Native 是一个 JavaScript 的框架,用来撰写实时的、可原生呈现 iOS 和 Android 的应用。

主页 https://facebook.github.io/react-native/
源码 https://github.com/facebook/react-native
发布版本 0.49

React native目录

1.开始 | Getting Started
2.指南 | Guides
3.APIs
4.组件:ActivityIndicator | Components: ActivityIndicator
5.组件:按钮 | Components: Button
6.组件:CheckBox | Components: CheckBox
7.组件:DatePickerIOS | Components: DatePickerIOS
8.组件:DrawerLayoutAndroid | Components: DrawerLayoutAndroid
9.组件:FlatList | Components: FlatList
10.组件:图像 | Components: Image
11.组件:KeyboardAvoidingView | Components: KeyboardAvoidingView
12.Components: ListView
13.Components: MaskedViewIOS
14.Components: Modal
15.Components: NavigatorIOS
16.Components: Picker
17.Components: PickerIOS
18.Components: ProgressBarAndroid
19.Components: ProgressViewIOS
20.Components: RefreshControl
21.Components: ScrollView
22.Components: SectionList
23.Components: SegmentedControlIOS
24.Components: Slider
25.Components: SnapshotViewIOS
26.Components: StatusBar
27.Components: Switch
28.Components: TabBarIOS
29.Components: TabBarIOS.Item
30.Components: Text
31.Components: TextInput
32.Components: ToolbarAndroid
33.Components: TouchableHighlight
34.Components: TouchableNativeFeedback
35.Components: TouchableOpacity
36.Components: TouchableWithoutFeedback
37.Components: View
38.Components: ViewPagerAndroid
39.Components: VirtualizedList
40.Components: WebView
41.创建 | Contributing
42.指南(Android) | Guides (Android)
43.指南(IOS) | Guides (iOS)
44.其他 | Miscellaneous