2016-08-11 221 views
0

在我的代碼中,我設置了我的iframe的allowfullscreen屬性,該屬性被SkyLight包圍,它是用於模態視圖的npm模塊,位於react.js爲什麼設置iframe的allowfullscreen屬性似乎沒有保留屬性

  <SkyLight dialogStyles={myBigGreenDialog} hideOnOverlayClicked ref="simpleDialog"> 
       <iframe src=url frameborder="0" width="960" height="569" allowfullscreen="true"></iframe>; 
      </SkyLight> 

然而,當我檢查我的網頁IFRAME沒有財產的allowFullScreen: pre editing

當我手動添加的屬性allowfullscreen="true"在控制檯,但是,IFRAME可以去全屏。

有誰知道如何確保allowfullscreen屬性存在,而無需通過控制檯手動添加它?

回答

3

請參閱the documentation

反應是區分大小寫,該屬性被稱爲allowFullScreen而不是allowfullscreen。它也是一個布爾屬性,所以true不是它的有效值。

<iframe src="http://example.com" frameborder="0" width="960" height="569" allowFullScreen></iframe> 

see a live demo

+0

這似乎正常工作!然而,這對我來說似乎很奇怪,因爲關於iframe的mozilla文檔明確指出它全部是小寫:https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe – MichaelGofron

+1

@MichaelGofron - 它沒有說它全部是小寫的,它給出了一個例子,並且對於這個例子全部使用小寫。 HTML屬性名稱不區分大小寫。 React不是HTML。 React區分大小寫。 React傾向於使用camelCase。 – Quentin

+0

對於任何需要React屬性的完整列表的人,你可以在這裏找到它:https://facebook.github.io/react/docs/tags-and-attributes.html – MichaelGofron

相關問題