From 155d292140788c8701212b216d521f9ff1633b61 Mon Sep 17 00:00:00 2001 From: wenlele Date: Fri, 9 Dec 2022 17:55:21 +0800 Subject: [PATCH] ceshi --- .../openness/components/container.jsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) 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 (
{videoWidth && videoHeight ? videoPlay ?