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. go 语言

    go语言(或 Golang)是Google在 2007 年开发的一种开源编程语言,于2009年11月开源,2012年发布go稳定版 go是非常年轻的一门语言,它的主要目标是“兼具Python 等动态语 ...

  2. shellinabox

    https://linux.cn/article-6046-1.html https://www.tecmint.com/shell-in-a-box-a-web-based-ssh-terminal ...

  3. [dart学习]第三篇:dart变量介绍 (二)

    本篇继续介绍dart变量类型,可参考前文:第二篇:dart变量介绍 (一) (一)final和const类型 如果你不打算修改一个变量的值,那么就把它定义为final或const类型.其中:final ...

  4. CodeForces - 468A

    Little X used to play a card game called "24 Game", but recently he has found it too easy. ...

  5. SSM项目思路整合NEW2

    上接于 https://www.cnblogs.com/shijinglu2018/p/10374541.html ...... 三)客户管理模块开发 说明:其实大致思路差不太多,都是首先根据前端页面 ...

  6. 内存管理 re模块

    # 内存垃圾回收机制: # 工作原理:引用计数 # 引用就+1 释放就是-1 当计数为0时 就会被垃圾回收机制回收 # 标记清除:解决循环引用导致的内存泄漏 # 标记:GC roots可以直接或间接访 ...

  7. sonarqube安装部署

    环境:Os:Centos 71.下载下载地址:https://www.sonarqube.org/sonarqube-7-7/我这里下载的是sonarqube-7-7sonarqube-7.7.zip ...

  8. BZOJ 4195: [Noi2015]程序自动分析 并查集+离散化

    LUOGU 1955BZOJ 4195 题目描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3...代表程序中出现的变量 ...

  9. [Python数据挖掘]第8章、中医证型关联规则挖掘

    一.背景和挖掘目标 二.分析方法与过程 1.数据获取 2.数据预处理  1.筛选有效问卷(根据表8-6的标准) 共发放1253份问卷,其中有效问卷数为930  2.属性规约 3.数据变换 ''' 聚类 ...

  10. Java笔试

    异常 Throwable是Java错误处理的父类,有两个子类:Error和Exception. Error:无法预期的严重错误,导致JVM虚拟机无法继续执行,几乎无法恢复捕捉的 Exception:可 ...