react native(八)加载网络数据 和chrome
2016-12-13 15:50
344 查看
进过一天的激烈战斗,UI界面终于成型,今天就开始加载网络数据
在官网上先看了一个短视频,发现了这个调试器chrome
1.好吧就先来说一说chrome(谷歌浏览器):
http://localhost:8081/debugger-ui打开这个网址
找到:视图-》开发者-》开发者工具 切到console目录
启动你的项目如是模拟器:command+D 选择Debug JS Remotely 就OK啦
这样就可以用console.log( )在你的项目中打印东西。
如
2.加载网络数据用fetch
//这是第二部分数据请求
componentDidMount() {
this.fetchData();
}
// 数据请求
fetchData() {
fetch(REQUEST_URL)
.then((response) => response.json())
.then((responseData) => {
console.log(responseData)
})
.catch((error) => {
console.error(error);
});
}
哈哈 一段代码搞定
在官网上先看了一个短视频,发现了这个调试器chrome
1.好吧就先来说一说chrome(谷歌浏览器):
http://localhost:8081/debugger-ui打开这个网址
找到:视图-》开发者-》开发者工具 切到console目录
启动你的项目如是模拟器:command+D 选择Debug JS Remotely 就OK啦
这样就可以用console.log( )在你的项目中打印东西。
如
2.加载网络数据用fetch
//这是第二部分数据请求
componentDidMount() {
this.fetchData();
}
// 数据请求
fetchData() {
fetch(REQUEST_URL)
.then((response) => response.json())
.then((responseData) => {
console.log(responseData)
})
.catch((error) => {
console.error(error);
});
}
哈哈 一段代码搞定
相关文章推荐
- react native listView(1) 加载网络数据简单版
- React-Native学习笔记 使用ListView加载网络数据
- React Native 中 网络访问 返回数据加载的问题Util
- React-native 网络图片无法加载问题
- react-native ListView加载大量数据时会占用大量内存导致应用崩溃
- React-native 网络图片无法加载问题
- React-Native基础_5.列表视图ListView 网络数据展示
- React-native学习过程 三 通过网络获取数据
- React Native第一个Demo(2)网络获取数据和ListView
- react-native(Fetch网络请求数据)
- React-Native网络请求加载界面
- 开发一个基于React Native的简易demo--读取网络数据并展示
- ReactNative学习实例(三) 使用fetch获取网络数据
- React-Native加载网络图片的问题
- React-native ListView 必须点击屏幕才会加载数据
- RN(react native)入坑指南-08,如何加载远程数据
- react-native 项目实战 -- 新闻客户端(4) -- 请求网络数据
- Android ListView加载网络数据和图片
- 网络通信框架Volley之一——获取String数据和图片的异步加载