本文介绍了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获取不是功能
发布评论