2015-06-20 67 views
2

我正在尝试使用原生的简单应用程序。我想从一个页面下载一个json数组并将其显示为一个listview。 我这样做React原生提取不是函数

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");

回答

5

你不需要require它。这是一个浏览器版本的polyfill,与浏览器版本一样,它始终可用于全局范围。

+0

未找到页面,“电影示例”,请更新您的答案。 – Aveek