关于react native的快捷键和常用规范

一:快捷键

1.让其自更新----shift+cmd+z 选择热更新

2.cmd+r ---重新刷新

3

二:常用规范:

1.文件也是一种组件 所以应该命名规则和组件名的命名规则相同 -----使用首字母大写 驼峰样NextPage

三:技巧 :

1.导致listview 出现滚动条解决办法 设置listview的

automaticallyAdjustContentInsets={false}

2.img使用技巧

1:网络资源

<Image source={{uri:'http://xxxxx/png'}}  />

2.本地资源

<Image source={require('image!lealogo')} />

3.背景图片backgroundImage(一定要设置后面的属性)

<Image source={require('image!lealogo')} transparent'}}> 

4.整屏背景<full screen> (先设置包裹flex:1 ,然后图片也设置flex:1 全部伸缩)


var TestCmp = React.createClass({
  render: function() { 
   return (  
   <View style={styles.imageContainer}>   
    <Image style={styles.image}
       source={{uri: 'http://lorempixel.com/200/400/sports/5/![enter image description here][2]'}} />   
   </View>    );  }})
 
var styles = StyleSheet.create({ 
 imageContainer: {    flex: 1,    alignItems: 'stretch'  }, 
 image: {    flex: 1  }});

flex布局

  1. view默认宽度为100%
  2. flex模拟 column 水平居中用alignItems, 垂直居中用justifyContent 方向为row的相反
  3. 基于flex能够实现现有的网格系统需求,且网格能够各种嵌套无bug

绝对定位和相对定位

和css的标准不同的是, 元素父容器不用设置position:'absolute|relative' . 默认相对于父容器进行位移.

http://www.jianshu.com/p/26dffb845046 自己看吧···