【发布时间】:2017-10-11 17:08:41
【问题描述】:
我正在尝试使用 react.js 从您的管道频道获取视频
我尝试使用 PHP CURL,得到了正确的响应。下面的代码显示空白页。 请帮忙。
import $ from 'jquery';
import React, { Component } from 'react';;
class iLotIndex extends Component {
constructor(props) {
super(props);
this.state = {video: []};
}
VideoList() {
return $.getJSON('https://www.googleapis.com/youtube/v3/search?key=AIzaxxxxxxxxxxxxxxxxxxxxx&channelId=UCexxxxxxxxxxxxxxxx&part=snippet,id&order=date&maxResults=20')
.then((data) => {
this.setState({ video : data.results });
});
}
render() {
this.VideoList().then(function(res){
this.state = {video: res};
});
return (
<div id="layout-content" className="layout-content-wrapper">
<div className="panel-list">
{this.state.video.map((item, i) =>{
return(
<h1>{item.items}</h1>
)
})}
</div>
</div>
)
}
}
【问题讨论】:
-
您的浏览器控制台有错误吗?
-
你能提供小提琴吗?还是钢笔还是jsben.ch?
-
不要混合使用 jQuery 和 React ;)
-
我会推荐superagent。
标签: javascript reactjs youtube youtube-data-api