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. typeHandler

    package com.cainiao.aeye.chdir.manager.tddl.Handler; import com.cainiao.aeye.chdir.core.enums.AudioF ...

  2. centos6删除nginx

    1.ps -ef|grep nginx 查看nginx进程 2.找到nginx相对应的位置 3.停止nginx服务: 4.删除nginx安装的相关路径(根据自己安装的情况来删除) 如果是yum安装,就 ...

  3. Eclipse中启动Tomcat报错:[There is insufficient memory for the Java Runtime Environment to continue.]的解决方案

    1,报错截图 2,报错信息 五月 08, 2018 9:57:58 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [Se ...

  4. Automatically populating $HTTP_RAW_POST_DATA is deprecated......

    Automatically populating $HTTP_RAW_POST_DATA is deprecated... 1 这个问题和PHP版本有关系,PHP 5.6已经废弃了$HTTP_RAW_ ...

  5. Linux Postfix 服务

    Linux Postfix 服务 postfix是Wietse Venema在IBM的GPL协议之下开发的MTA(邮件传输代理)开源软件.能够很好地兼容 Sendmail服务程序,可以方便 Sendm ...

  6. linux常用英文单词记录

    1.skip 跳过忽略 2.next 下一步3.hostname 主机名4.password 密码5.complete 完成6.network 网络7.conf config configuratio ...

  7. Selenium及Headless Chrome抓取动态HTML页面

    一般的的静态HTML页面可以使用requests等库直接抓取,但还有一部分比较复杂的动态页面,这些页面的DOM是动态生成的,有些还需要用户与其点击互动,这些页面只能使用真实的浏览器引擎动态解析,Sel ...

  8. 关于js中的类式继承

    ; }; ,,]; }; ); ; }; //子类 function Bb(){ }; var F=new f(); F.prototype=Aa.prototype;//此处只能传递方法,没有办法传 ...

  9. 论文笔记:Auto-ReID: Searching for a Part-aware ConvNet for Person Re-Identification

    Auto-ReID: Searching for a Part-aware ConvNet for Person Re-Identification 2019-03-26 15:27:10 Paper ...

  10. Cordova 笔记

    npm instal -g cordova 安装 卸载cordova npm unistall cordova -g 安装指定版本 npm install -g cordova@ 1.创建应用项目及目 ...