我试图用react.js取的Youtube视频动态
我用PHP卷曲试图获取您从管通道的视频,我也得到适当的反应。下面的代码显示空白页面。 请帮忙。
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? – MehulJoshi
不要混用jQuery和React;) – errata