2017-07-12 35 views
1

我试图嵌入上它起到了Vimeo的与FRAMEBORDER和将allowFullScreen属性,象这样一个MyOwnComponent一个iframe:反应,和/打字稿不能识别iframe的性能

const MyOwnVimeoComponent =() => { 
return (
    <div> 
     <iframe 
      src="https://player.vimeo.com/video/VIMEOID" 
      width="640" 
      height="360" 
      frameborder="0" 
      webkitallowfullscreen 
      mozallowfullscreen 
      allowfullscreen 
     ></iframe> 
    </div> 
);} 

但是,我得到的错误是:

[ts] Property 'frameborder' does not exist on type 'HTMLProps<HTMLIFrameElement>' 

同为webkitallowfullscreenmozallowfullscreenallowfullscreen

研究在堆栈中的其他类似的问题后溢出它导致我检查Typescript的lib.d.ts文件并查看<HTMLIFrameElement>接口和变量声明。

该接口的确具有frameborderallowfullscreen类型的属性,但它仍然会引发该错误。我会理解它是否只为webkitallowfullscreenmozallowfullscreen抛出错误,但我通常对这里发生的事情感到困惑。

如果任何人都可以指出我在正确的方向,将不胜感激。

供参考,在这里是什么似乎是lib.d.ts文件的相关部分:

interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { 
align: string; 
allowFullscreen: boolean; 
allowPaymentRequest: boolean; 
border: string; 
readonly contentDocument: Document; 
readonly contentWindow: Window; 
frameBorder: string; 
frameSpacing: any; 
height: string; 
hspace: number; 
longDesc: string; 
marginHeight: string; 
marginWidth: string; 
name: string; 
noResize: boolean; 
onload: (this: HTMLIFrameElement, ev: Event) => any; 
readonly sandbox: DOMSettableTokenList; 
scrolling: string; 
src: string; 
vspace: number; 
width: string; 
addEventListener<K extends keyof HTMLIFrameElementEventMap>(type: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => any, useCapture?: boolean): void; 
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; 
} 

declare var HTMLIFrameElement: { 
    prototype: HTMLIFrameElement; 
    new(): HTMLIFrameElement; 
} 

回答

1

正如你可以在lib.d.ts文件中看到,它应该是frameBorder,不frameborder

别担心,我花了一段时间才发现它!