【发布时间】:2018-07-13 12:57:48
【问题描述】:
Typescript 似乎在这里对我不利。这是我要嵌入的内容:
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/BLAH?showinfo=0"
frameBorder="0"
allow="autoplay; encrypted-media"
allowFullScreen></iframe>
问题是allow属性:
TS2339: Property 'allow' does not exist on type 'DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>'.
...这是真的,它不在 index.d.ts 中。如何强制添加此属性,或以某种方式将iframe 转换为任何类型等?
【问题讨论】:
-
如果移动到 react 16 不是一个选项 - 仍然有一个技巧可以让它工作 - 查看这个问题 stackoverflow.com/questions/31273093/…
标签: reactjs typescript youtube