diff --git a/code/VideoAccess-VCMP/web/client/src/sections/openness/components/container.jsx b/code/VideoAccess-VCMP/web/client/src/sections/openness/components/container.jsx index 52821c6..7107b76 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/openness/components/container.jsx +++ b/code/VideoAccess-VCMP/web/client/src/sections/openness/components/container.jsx @@ -12,8 +12,12 @@ const Container = ({ videoObj, pageSize, showHeader, videoPlay, mould }) => { useEffect(() => { const resize_ = async () => { - // await setVideoWidth(document.getElementById('video' + videoObj.key).clientWidth) - // await setVideoHeight(document.getElementById('video' + videoObj.key).clientHeight) + let video = document.getElementById('video' + videoObj.key) + if (video) { + await setVideoWidth(video.clientWidth) + await setVideoHeight(video.clientHeight) + } + } resize_() window.addEventListener('resize', resize_); //只要窗口殴大小发生像素变化就会触发 @@ -23,22 +27,25 @@ const Container = ({ videoObj, pageSize, showHeader, videoPlay, mould }) => { }, []) useEffect(() => { - // setVideoWidth(document.getElementById('video' + videoObj.key).clientWidth) - // setVideoHeight(document.getElementById('video' + videoObj.key).clientHeight) + let video = document.getElementById('video' + videoObj.key) + if(video){ + setVideoWidth(video.clientWidth) + setVideoHeight(video.clientHeight) + } }, [pageSize, showHeader]) // console.log(videoWidth, videoHeight); return (