使用 Youtube API 在网络服务器上显示视频时如何修复播放 ID 错误?

How to Fix Playback ID Error when using Youtube API to display videos on a webserver?

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

尝试用大括号替换冒号。

e.g. $(item.id.videoId) to ${item.id.videoId}