<iframe width="560" height="315" src="https://www.youtube.com/embed/视频编码" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
把这段代码嵌入网页发现不能自动播放,在网上找了很多文章,无非是在后面加?autoplay=1,但是还是不能自动播放。
找到解决办法:
在网址后面添加?enablejsapi=1&autoplay=1&
这是我的原创呦