React Native获取不是功能

编程入门 行业动态 更新时间:2024-10-09 06:28:40
本文介绍了React Native获取不是功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试对一个简单的应用程序使用本机响应.我想从页面下载一个json数组并将其显示为列表视图. 我正在这样做

I'm trying to use react native for a simple app. I want to download a json array from a page and display it as a listview. I'm doing this

var listApp = React.createClass({ fetchData : function() { fetch(requestURL) .then((response) => response.json()) .then((responseData) => { console.log(responseData); }) .done(); }, componentDidMount: function() { this.fetchData(); this.setState({ dataSource: this.state.dataSource.cloneWithRows(elements) }); },

但是这样做,我从Chrome调试器收到错误fetch is not a function.我以这种方式获取var fetch = require("fetch");

But doing this I get the error fetch is not a function from Chrome debugger. I get fetch in this way var fetch = require("fetch");

推荐答案

您无需require.它是浏览器版本的polyfill,就像浏览器版本一样,它始终可用于全局范围.

You don't need to require it. It's a polyfill for the browser version, and like the browser version it's always available to the global scope.

更多推荐

React Native获取不是功能

本文发布于:2023-11-27 21:25:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   React   Native

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!