比较简单的项目

//index.js
/** @format */ import {AppRegistry} from 'react-native';
//默认创建的类
import App from './App';
//json
import {name as appName} from './app.json';
//FlatList类
import DWBFlatList from './DWBHomeFlatList' import DWBTestVC from './DWBTestVC' import DWBTButton from './DWBTButton' // import DWBSwipeout from './DWBSwipeout' import DWBNavVC from './DWBNavVC'
import DWBTouchableOpacity from './DWBTouchableOpacity' import DWBSectionList from './DWBSectionList' import DWBActionButton from './DWBActionButton' //修改这里可以切换不同的类显示: => App
AppRegistry.registerComponent(appName, () => DWBFlatList); // react-native关闭所有黄色警告,将这两句话加在index.js文件中,放在AppRegistry.registerComponent('App', () => App)之前。
console.ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please use BackHandler instead.','source.uri should not be an empty string','Invalid props.style key']; console.disableYellowBox = true // 关闭全部黄色警告

//DWBHomeFlatList.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
FlatList,
TouchableOpacity, Button,
} from 'react-native'; // 初始化数据
var Arr = [
{name:'河北省',},
{name:'山西省',},
{name:'辽宁省',},
{name:'吉林省',},
{name:'黑龙江省',},
{name:'江苏省',},
{name:'浙江省',},
{name:'福州省',}]; export default class MyFlatList extends Component { render() {
//给数据追加一个key的字段,不然会有警告的,参数数组中的每一项,需要包含 key 值作为唯一标示
for (var i = 0; i < Arr.length; i++) {
Arr[i]['key'] = i;
}
return (
//初始化FlatList
<View style={styles.container}>
<FlatList style={styles.FlatListStyle}
data = {Arr}
ListHeaderComponent={this.ListHeaderComponent.bind(this)}
ListFooterComponent={this.ListFooterComponent.bind(this)}
renderItem={this.renderItemView.bind(this)}
//分割线组件
ItemSeparatorComponent={ItemDivideComponent}
> </FlatList> </View>
);
} //列表的每一行
renderItemView({item,index}){
return( <TouchableOpacity onPress={()=>{
this.Cellheader(item)}
}
>
<View style={{
backgroundColor:'#ffffff',//背景色
height:59,//view高度
justifyContent:'center',//内容上下居中
alignItems: 'center'//内容左右居中
}}> <Text>{item.name}</Text> </View> </TouchableOpacity>
);
} //点击每一行的对象
Cellheader(data){
alert(data.name);
} //定义页头
ListHeaderComponent(){
return(
<View style={{height:140,backgroundColor:'red',justifyContent: 'center',}}>
<Text>我是页头</Text>
</View>
);
}
//定义页脚
ListFooterComponent(){
return(
<View style={{height:140,backgroundColor:'yellow',justifyContent: 'center',}}>
<Text>我是页脚</Text>
</View>
);
}
} // //设置分割线
// renderSeparator(){
// return (
// <View style={{height: 1, backgroundColor: 'skyblue'}}></View>
// );
// }; class ItemDivideComponent extends Component {
render() {
return (
<View style={{height: 1, backgroundColor: 'skyblue'}}></View>
);
}
}; const styles = StyleSheet.create({
//控制器属性
container: {
flex: 1,
flexDirection: 'column',
justifyContent: 'space-between',
backgroundColor: '#F5FCFF',
},
//FlatList属性
FlatListStyle:{
backgroundColor:'#f6f6f6',
flex:1,
marginTop:64,
marginBottom: 100,
// width:300
} });
//DWBActionButton.js
import React, { Component } from 'react';
import { StyleSheet, View,Text,Alert } from 'react-native';
import ButtonMy from 'apsl-react-native-button' export default class ActionButton extends Component { render() {
return ( <View style={styles.ViewSyt}>
<ButtonMy style={{backgroundColor: '#c771ec'}} onPress={()=>{
Alert.alert('我是一个button');
}}>
<View style={styles.actionButtonIcon}>
<Text style={styles.actionButtonIcon}>我是一个button</Text>
</View>
</ButtonMy>
</View> );
} } const styles = StyleSheet.create({
ViewSyt:{
flex:1,
marginTop:100,
fontSize: 20,
height: 40,
color: 'white', }, actionButtonIcon: {
fontSize: 20,
height: 22,
color: 'white',
},
});

比较基础,=-=

【水滴石穿】MyFirstRNDemo的更多相关文章

  1. iOS 开发笔记 -- 各种细枝末节的知识(水滴石穿)

    在此总结整理,遇到的各种的小问题: 1.通过从字典(数组)中取出的NSString的length==0 作为if的判断条件导致的carsh: 由于在字典中通过Key取出值之后直接做了length相关操 ...

  2. 【水滴石穿】react-native-book

    先推荐一个学习的地址:https://ke.qq.com/webcourse/index.html#cid=203313&term_id=100240778&taid=12778558 ...

  3. 【水滴石穿】rnTest

    其实就是一个小的demo,不过代码分的挺精巧的 先放地址:https://github.com/linchengzzz/rnTest 来看看效果 确实没有什么可以说的,不过代码部分还行 先入口文件 / ...

  4. 【水滴石穿】rn_statusbar

    先放项目地址https://github.com/hezhii/rn_statusbar 来看一下效果 咩有感觉很怎么样,看代码 根入口文件 //index.js //看代码我们知道入口是app.js ...

  5. 【水滴石穿】react-native-ble-demo

    项目的话,是想打开蓝牙,然后连接设备 点击已经连接的设备,我们会看到一些设备 不过我这边在开启蓝牙的时候报错了 先放作者的项目地址: https://github.com/hezhii/react-n ...

  6. 【水滴石穿】ReactNative-Redux-Thunk

    老实说,运行出来的项目让人失望,毕竟我想看各种有趣的demo啊- 先放上源码地址:https://github.com/ludejun/ReactNative-Redux-Thunk 我们来一起看看代 ...

  7. 【水滴石穿】mobx-todos

    我觉得代码在有些程序员手里,就好像是画笔,可以创造很多东西 不要觉得创意少就叫没有创意,每天进步一点点,世界更美好 首先源码地址为:https://github.com/byk04712/mobx-t ...

  8. 【水滴石穿】ReactNativeMobxFrame

    项目地址如下:https://github.com/FTD-ZF/ReactNativeMobxFrame 应该可以说的是,项目也只是一个花架子,不过底部的tab稍微改变了 我们一起来看代码 //in ...

  9. 【水滴石穿】react-native-aze

    说个题外话,早上打开电脑的时候,电脑变成彩色的了,锅是我曾经安装的一个chrome扩展,没有经过我的同意开启了 (也许是昨天迷迷糊糊开启了) 上午运行项目都不成功,还以为被黑客攻击了---然后下午就排 ...

随机推荐

  1. 大数据处理也要安全--关于MaxCompute的安全科普

    [TOC] 1.企业大数据处理现状 当今社会数据收集手段不断丰富,行业数据大量积累,数据规模已增长到了传统软件行业无法承载的海量数据(百GB.TB乃至PB)级别.基于此,阿里云推出有了一套快速.完全托 ...

  2. Spring注解驱动开发(三)-----自动装配

    自动装配 概念 Spring利用依赖注入(DI),完成对IOC容器中中各个组件的依赖关系赋值. @Autowired-----自动注入 1.默认优先按照类型去容器中找对应的组件 application ...

  3. MATLAB技巧—sort和sortrows函数

    MATLAB技巧-sort和sortrows函数 1.sort函数 sort函数用于对数据进行排序,通过help sort命令,可以查找到sort函数的具体用法: Y = SORT(X,DIM,MOD ...

  4. Docker镜像之commit

    利用 commit 理解镜像构成 基础知识 镜像是容器的基础,每次执行 docker run 的时候都会指定哪个镜像作为容器运行的基础.在之前的例子中,我们所使用的都是来自于 Docker Hub 的 ...

  5. 通过url方式传递中文参数时出现的中文乱码问题的处理

    1.通过url将参数[会有中文的情况]传递到另外一个页面: window.location.href = "/XXXX/XXXX?searchcontent=" + Content ...

  6. Redis 分布式锁进化史

    按:系统架构经过多年演进,现在越来越多的系统采用微服务架构,而说到微服务架构必然牵涉到分布式,以前单体应用加锁是很简单的,但现在分布式系统下加锁就比较难了,我之前曾简单写过一篇文章,关于分布式锁的实现 ...

  7. 简单易学的机器学习算法——基于密度的聚类算法DBSCAN

    一.基于密度的聚类算法的概述     最近在Science上的一篇基于密度的聚类算法<Clustering by fast search and find of density peaks> ...

  8. webservice作用(优,缺点;作用)

    1其实我们平时的应用,有一方面考虑是部署方便,维护容易~!如果是DLL,部署,更新需要每个应用了这个DLL的应用程序都作相应的引用更新...而如果用了Ws,则不用,因为它通过网络部署,通过网络引用,基 ...

  9. 简单linux查询

    1查看日志异常 tailf nohup.out|grep ERROR -A 3 --color   tailf nohup.out|grep ERROR|grep chunk -A 3 -B 3 -- ...

  10. TensorFlow的安装 (python3.6在有pip的条件下如何安装TensorFlow)

     1.Window,MacOS,Linux都已支持Tensorflow.  2.Window用户只能使用python3.5(64bit).MacOS,Linux支持python2.7和python ...