【发布时间】:2021-07-25 12:46:01
【问题描述】:
Youtube 播放器正确加载,但视频在点击播放时显示播放错误,并且缩略图也无法加载。有人可以指出我可能做错了什么。
$(document).ready(function(){
var API_KEY = ""; // Did not include API here but I have it included it my code
var search = "soccer";
var video = '';
videoSearch(API_KEY, search);
function videoSearch(API_KEY, search){
$.get("https://www.googleapis.com/youtube/v3/search?key=" + API_KEY
+ "&type=video&part=snippet&maxResults=12&q=" + search, function(data){
console.log(data);
data.items.forEach(item => {
video = `
<iframe width="420" height="315" src="http://www.youtube.com/embed/$(item.id.videoId)" frameborder="0" allowfullscreen></iframe>
`
$("#videos").append(video);
});
})
}
})
【问题讨论】:
-
欢迎来到 Stack Overflow。你能用你的代码创建 JSFiddle 吗?并解释问题?
标签: javascript api youtube-api youtube-data-api