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. [HDU 5029] Relief grain

    Relief grain Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)T ...

  2. (转载)CentOS: 开放80、22、3306端口操作

    (转载)http://blog.sina.com.cn/s/blog_3eba8f1c0100tsox.html #/sbin/iptables -I INPUT -p tcp --dport 80 ...

  3. powerdesigner导出SQL时大写转换

    打开物理模型,点击菜单“Tools->Execute Commands -> Edit/Run Script...",或者快捷键(Ctrl+Shift+X)执行下面vbscrip ...

  4. Javaweb之JavaScript结合(二)

    1.js的String对象 ** 创建String对象 *** var str = "abc"; ** 方法和属性(文档) *** 属性 length:字符串的长度 *** 方法 ...

  5. bzoj 1228 [SDOI2009]E&D(sg函数,找规律)

    Description 小E 与小W 进行一项名为“E&D”游戏.游戏的规则如下:桌子上有2n 堆石子,编号为1..2n.其中,为了方便起见,我们将第2k-1 堆与第2k 堆(1 ≤ k ≤ ...

  6. SPI协议及其工作原理浅析

    转载自:http://bbs.chinaunix.net/thread-1916003-1-1.html一.概述. SPI, Serial Perripheral Interface, 串行外围设备接 ...

  7. HW5.25

    public class Solution { public static void main(String[] args) { System.out.println(convertMillis(55 ...

  8. HW4.46

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  9. dublin core实例

    <?xml version="1.0"?> <metadata xmlns="http://example.org/myapp/" xmlns ...

  10. Jquery UI 组合树 - ComboTree 集成Wabacus4.1 代码剖析

    Jquery UI 1.3 (组合树 - ComboTree ) 集成Wabacus4.1 集成Spring 代码剖析 使用时,请下载需要Jquery ui包进行配置 combotree.js 的代码 ...