如何使用 React + Typescript 嵌入 YouTube iframe?

sti*_*ure 6 youtube typescript reactjs

打字稿似乎在这里对我不利。这是我想要嵌入的内容:

<iframe 
    width="560" 
    height="315" 
    src="https://www.youtube.com/embed/BLAH?showinfo=0" 
    frameBorder="0" 
    allow="autoplay; encrypted-media" 
    allowFullScreen></iframe>
Run Code Online (Sandbox Code Playgroud)

问题是allow属性:

TS2339: Property 'allow' does not exist on type 'DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>'.
Run Code Online (Sandbox Code Playgroud)

...这是真的,它不在 index.d.ts 中。如何强制添加此属性,或以某种方式强制转换iframe为任何类型等?

sti*_*ure 5

答案是将属性从 更改allow为data-allow。