import React, { Component } from 'react'
import { Platform, StyleSheet, Text, View,Image ,FlatList} from 'react-native'
// import { createBottomTabNavigator,createStackNavigator, createAppContainer } from 'react-navigation'
// import HomeScreen from './HomeScreen'
// import ProfileScreen from './SecondScreen'
// const navigator = createStackNavigator({
// Home: { screen: HomeScreen },
// Profile: { screen: ProfileScreen },
// },
// {
// initialRouteName: 'Home',
// /* The header config from HomeScreen is now here */
// defaultNavigationOptions: {
// headerStyle: {
// backgroundColor: '#f4511e',
// },
// headerTintColor: '#fff',
// headerTitleStyle: {
// fontWeight: 'bold',
// },
// },
// navigationOptions: {
// tabBarLabel: 'Home!',
// },
// }
// );
// const TabNavigator = createBottomTabNavigator({
// Home: HomeScreen,
// Profile: ProfileScreen,
// });
class Item extends Component{
render(){
let imguri='http://blog.zangzhihong.com/'+this.props.content.thumbnail;
return(
<View STYLE={{flex:1}}>
<View >
<Text style={{paddingLeft:10,fontSize:16,color: '#3f4452'}}>{this.props.content.title}</Text>
</View>
<View style={{flexDirection:'row',padding:10}}><Text>时间:{this.props.content.time}</Text><Text style={{marginLeft:10}}>分类:{this.props.content.column}</Text><Text style={{marginLeft:10}}>热度:{this.props.content.visitnumber}</Text></View>
<View style={{flexDirection:'row'}}>
<View style={{height:150,width:200}}>
<Image style={{height:150,width:200}} source={{uri:imguri}}></Image>
</View>
<View style={{flex:1,paddingLeft:10}}>
<Text numberOfLines={8} >
{this.props.content.article}
 
</Text>
</View>
</View>
<View style={{flexDirection:'row',justifyContent:'flex-end',marginTop:15}}><Text style={{padding:5, borderColor:'#ccc',borderWidth:1}}>阅读全文</Text></View>
</View>
)
}
}
// const App = createAppContainer(TabNavigator)
export default class App extends Component{
constructor(props){
super(props);
this.state={list:[]}
// this.getList=this.getList.bind(this)
}
componentDidMount(){
 
this.getList()
}
getList(){
let content ={currentPage:1,pageSize:15}
fetch('http://blog.zangzhihong.com/api/getarticle',{method:'post',body:JSON.stringify(content)}).then(response => response.json()).
then(responseJson=>{
 
this.setState({list:responseJson.data});
 
})
}
render(){
return(
<FlatList data={this.state.list
} renderItem={({item}) => <View style={{paddingLeft:10,paddingRight:10,borderBottomColor:'#fcfcfc',borderWidth:0.5}}>
<Item content={item}></Item>
 
</View>}
>
</FlatList>
 
 
)
}
}
// const styles = StyleSheet.create({
// container: {
// flex: 1,
// justifyContent: 'center',
// alignItems: 'center',
// backgroundColor: '#F5FCFF'
// },
// welcome: {
// fontSize: 20,
// textAlign: 'center',
// margin: 10
// },
// instructions: {
// textAlign: 'center',
// color: '#333333',
// marginBottom: 5
// }
// })

react native练习的更多相关文章

  1. React Native 之 Text的使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  2. React Native环境配置之Windows版本搭建

    接近年底了,回想这一年都做了啥,学习了啥,然后突然发现,这一年买了不少书,看是看了,就没有完整看完的.悲催. 然后,最近项目也不是很紧了,所以抽空学习了H5.自学啃书还是很无趣的,虽然Head Fir ...

  3. 史上最全Windows版本搭建安装React Native环境配置

    史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...

  4. 【腾讯Bugly干货分享】React Native项目实战总结

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/577e16a7640ad7b4682c64a7 “8小时内拼工作,8小时外拼成长 ...

  5. React Native环境搭建以及几个基础控件的使用

    之前写了几篇博客,但是没有从最基础的开始写,现在想了想感觉不太合适,所以现在把基础的一些东西给补上,也算是我从零开始学习RN的经验吧! 一.环境搭建 首先声明一下,本人现在用的编辑器是SublimeT ...

  6. React Native组件介绍

    1.React Native目前已有的组件 ActivityIndicatorIOS:标准的旋转进度轮; DatePickerIOS:日期选择器: Image:图片控件: ListView:列表控件: ...

  7. React Native图片控件的使用

    首先定义组件 import { AppRegistry, StyleSheet, Text, View, Image,} from 'react-native'; 然后将render返回中的模版增加I ...

  8. react-native学习笔记--史上最详细Windows版本搭建安装React Native环境配置

    参考:http://www.lcode.org/react-native/ React native中文网:http://reactnative.cn/docs/0.23/android-setup. ...

  9. windows 7下React Native环境配置

    React Native 是 Facebook 推出的一个用 Java 语言就能同时编写 ios,android,以及后台的一项技术,它可以做到实时热更新 .FaceBook 也号称这们技术是 “Le ...

  10. React Native初探

    前言 很久之前就想研究React Native了,但是一直没有落地的机会,我一直认为一个技术要有落地的场景才有研究的意义,刚好最近迎来了新的APP,在可控的范围内,我们可以在上面做任何想做的事情. P ...

随机推荐

  1. C# 解析html中筛选class的问题

    C# 解析html中筛选class的问题 C# html解析 class 类  当我们用C#的.net解析html的时候,当html的元素没有id,并且没有过多的属性供筛选,只能通过class=&qu ...

  2. Redis学习-持久化机制

    Redis持久化的意义 在于故障恢复 比如你部署了一个redis,作为cache缓存,当然也可以保存一些较为重要的数据 如果没有持久化的话,redis遇到灾难性故障的时候(断电.宕机),就会丢失所有的 ...

  3. MySQL表的操作

    一.存储引擎(了解) 前几节我们知道mysql中建立的库===>文件夹,库中的表====>文件 现实生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不同的处理机制:比如处理文 ...

  4. 关于.vbs文件恶搞,小伙伴电脑的

    这是,VBS是基于Visual Basic的脚本语言.VBS的全称是:Microsoft Visual Basic Script Edition.(微软公司可视化BASIC脚本版). 其语言类似Vis ...

  5. mysql和oracle分页查询

    MYSQL分页查询 方式1: select * from table order by id limit m, n; 该语句的意思为,查询m+n条记录,去掉前m条,返回后n条记录.无疑该查询能够实现分 ...

  6. 利用python抓取页面数据

    1.首先是安装python(注意python3.X和python2.X是不兼容的,我们最好用python3.X) 安装方法:安装python 2.安装成功后,再进行我们需要的插件安装.(这里我们需要用 ...

  7. bzoj 4767 两双手 - 动态规划 - 容斥原理

    题目传送门 传送门I 传送门II 题目大意 一个无限大的棋盘上有一只马,设马在某个时刻的位置为$(x, y)$, 每次移动可以将马移动到$(x + A_x, y + A_y)$或者$(x + B_x, ...

  8. Python脚本备份

    #!/usr/bin/python3 # -*- coding:utf- -*- # 保证源程序可以输入汉字 print bool([]) # 任何为零的数字或空集(空列表.空元组和空字典等)均为Fa ...

  9. mfc动态控件生成

    1.变量.函数声明 std::vector<CButton*>pBtn; afx void OnBtnClik(UINT uID);//回调函数 2.分配空间 pBtn.resize(50 ...

  10. 清除本地SVN信息

    C:\Documents and Settings\yangxf\Application Data\Subversion\auth 这个目录下删除svn文件夹即可