import React,{ Component } from 'react';

import {

AppRegistry,

ListView,

Image,

Text,

StyleSheet,

View,

TouchableHighlight

} from 'react-native';

class SimpleNavigationApp extends Component{

constructor(props){

super(props);

this.state = {

title:'',

slug:'',

};

}

fetchData = ()=>{

fetch('http://bbs.reactnative.cn/api/category/3')

.then((response)=>response.json())

.then((jsondata)=>{

this.setState({

title:jsondata.topics[0].title,

slug:jsondata.topics[0].slug,

})

})

.catch((error)=>{

console.warn(error);

});

};

render() {

return (

<View style={{flex: 1, paddingTop: 22}}>

<Text>

RN中文网头条文章:

</Text>

<Text>

{this.state.title}

</Text>

<Text style={styles.bigblue}>

{this.state.slug}

</Text>

<TouchableHighlight onPress={this.fetchData}>

<Text>提交</Text>

</TouchableHighlight>

</View>

);

}};

const styles = StyleSheet.create({

bigblue: {

color: 'blue',

fontWeight: 'bold',

fontSize: 30,

},

red: {

color: 'red',

},

});

AppRegistry.registerComponent('SimpleNavigationApp', () => SimpleNavigationApp);

Fetch的使用的更多相关文章

  1. Git 少用 Pull 多用 Fetch 和 Merge

    本文有点长而且有点乱,但就像Mark Twain Blaise Pascal的笑话里说的那样:我没有时间让它更短些.在Git的邮件列表里有很多关于本文的讨论,我会尽量把其中相关的观点列在下面. 我最常 ...

  2. git提示:Fatal:could not fetch refs from ....

    在git服务器上新建项目提示: Fatal:could not fetch refs from git..... 百度搜索毫无头绪,最后FQgoogle,找到这篇文章http://www.voidcn ...

  3. sublime 插件推荐: Nettuts+ Fetch

    Nettuts+ Fetch github地址:Nettuts-Fetch 在sublime中直接用 ctrl+shift+P -> pci -> Nettuts-Fetch 即可下载 这 ...

  4. git pull和git fetch的区别

    Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge Git fetch origin master git log ...

  5. Hibernate之加载策略(延迟加载与即时加载)和抓取策略(fetch)

    假设现在有Book和Category两张表,表的关系为双向的一对多,表结构如下: 假设现在我想查询id为2的那本书的书名,使用session.get(...)方法: Session session=H ...

  6. SQL Server 2012提供的OFFSET/FETCH NEXT与Row_Number()对比测试(转)

    原文地址:http://www.cnblogs.com/downmoon/archive/2012/04/19/2456451.html 在<SQL Server 2012服务端使用OFFSET ...

  7. Attempt to fetch logical page (...) in database 2 failed. It belongs to allocation unit xxxx not to xxx

    今天一个同事说在一个生产库执行某个存储过程,遇到了错误: Fatal error 605 occurred at jul 29 2014 我试着执行该存储过程,结果出现下面错误,每次执行该存储过程,得 ...

  8. Fetch:下一代 Ajax 技术

    Ajax,2005年诞生的技术,至今已持续了 10 年.它是一种在客户端创建一个异步请求的技术,本质上它不算创新,是一组技术的组合.它的核心对象是 XMLHttpRequest. 简单回顾下历史 19 ...

  9. 在 JS 中使用 fetch 更加高效地进行网络请求

    在前端快速发展地过程中,为了契合更好的设计模式,产生了 fetch 框架,此文将简要介绍下 fetch 的基本使用. 我的源博客地址:http://blog.parryqiu.com/2016/03/ ...

  10. 解决:error: Cannot fetch repo (TypeError: expected string or buffer)

    同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...

随机推荐

  1. 关于css样式的看法

    1.通常有两种方式,第一种是直接写在页面标签中,通过属性style,另一种是通过标签选择器赋样式 第一种方式,就是每一个标签都需要写一遍样式,同时没有做到样式和内容的分离,不方便以后的样式替换,主题的 ...

  2. 使用C#调用Python脚本,带参数列表 z

    static void Main(string[] args) { string[] strArr;//参数列表 string sArguments = @"Pythons.py" ...

  3. NOIP2013 货车运输 LCA倍增+最大生成树

    #include <cstdio> #include <iostream> #include <ctime> #include <vector> #in ...

  4. HDU 2682

    思路:由于题目对能相连的点有限制,必须将这些点处理,能相连的点合并到一个集合中,最后查看是否所有点都在一个集合里,若都在说明是一个连通图,存在最小生成树,否则图不连通,不存在最小花费. #includ ...

  5. Sum It Up

    http://acm.hdu.edu.cn/showproblem.php?pid=1258 Sum It Up Time Limit: 2000/1000 MS (Java/Others)    M ...

  6. The Donkey of Gui Zhou

    Problem Description There was no donkey in the province of Gui Zhou, China. A trouble maker shipped ...

  7. HDOJ-ACM1021(JAVA)

    题意: 斐波拉契数列的另外一个变型,如果F(n)能被3整除,则输出yes,否则输出no.(n<1000000) 解题思路: 看到(n<1000000)这个条件,有点感觉递归量有点大,因此要 ...

  8. windows 7 中将“我的电脑”锁定到任务栏

    1.在桌面右击->新建->快捷方式 2.输入%SystemRoot%\explorer.exe /E,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}点击下 ...

  9. libmad和libmpg123解码mp3在安卓手机上的比较

    libmad和libmpg123解码mp3在安卓手机上的比较1. libmad 选自 http://sourceforge.net/projects/mad  libmad-0.15.1b.tar.g ...

  10. HTML 网页游戏 2048

    新手只会一点html和css,javascript基本不会,更别提jQuery了= = 跟着慕课网的教学视频(视频地址:http://www.imooc.com/learn/76)一点点做的,由于自己 ...