1
我有一個反應組件,其中包含一個使用html5 FullScreen API(RequestFullScreen)全屏顯示的元素。在Reactjs中退出全屏
例如,
handleFullScreenClick() {
if (this.refs.myElement.requestFullscreen) {
this.refs.myElement.requestFullscreen();
} else if (this.refs.myElement.mozRequestFullScreen) {
this.refs.myElement.mozRequestFullScreen();
} else if (this.refs.myElement.webkitRequestFullscreen) {
this.refs.myElement.webkitRequestFullscreen();
}
}
現在,我希望能夠當按下例如按鈕退出全屏。當我搜索全屏API時,我看到ExitFullScreen函數必須由文檔元素調用,文檔元素不能被反應組件訪問。
是否有任何方法可以訪問我的反應組件中的文檔元素以調用ExitFullScreen函數?
感謝很多:)
請問一些代碼? – user1120808
增加了我將元素放入全屏的方式 – Gstackr
'document'全局可訪問,所以您可以使用它。 – dfsq