Javascript Youtube iframe api a.u()不是函数

Javascript Youtube iframe api a.u()不是函数,javascript,youtube,youtube-iframe-api,Javascript,Youtube,Youtube Iframe Api,我正在react应用程序中实现youtube iframe api,但遇到此错误 www.widgetapi.js:格式化:884未捕获类型错误:a.u不是函数 在Ya(www.widgetapi.js:formatted:884) 在Object.W(www.widgetapi.js:formatted:778) 在Object.Y[as Player](www.widgetapi.js:formatted:973) 在e.value(Video.js:120) 在window.onYouTu

我正在react应用程序中实现youtube iframe api,但遇到此错误

www.widgetapi.js:格式化:884未捕获类型错误:
a.u
不是函数
在Ya(www.widgetapi.js:formatted:884)
在Object.W(www.widgetapi.js:formatted:778)
在Object.Y[as Player](www.widgetapi.js:formatted:973)
在e.value(Video.js:120)
在window.onYouTubeIframeAPIReady上(Video.js:74)
www.widgetapi.js:formatted:1185
www.widgetapi.js:formatted:1189

下面是函数

loadYoutube(){
 id='74YQWthFz8g'
 var data = {
        height: this.props.height,
        width: this.props.width,
        playerVars: {
            enablejsapi: 1,
            autoplay: 1, //
            controls: 0, //Turn off video controls
            modestbranding: 1, //Turn off Youtube Logo
            rel: 0, //Disable related videos at the end
            showinfo: 0, //Disable diplay of title
            disablekb: 0 //disable the keyboard
        },
        videoId: id,
        events: {
            onReady: function() {
                console.log('ready');
            },
            onStateChange: function() {
                console.log('statechange');
            }
        }
    };
    player = window.YT.Player('ytubeplayer', data);
 }
 window.onYouTubeIframeAPIReady= (e)=>{this.loadYoutube()}

我有这个问题。对我来说,通过执行
player=newyt.player('ytubeplayer',data)
解决了这个问题

它是一个构造函数,因此需要使用
new
关键字

希望这也能帮你解决