Bläddra i källkod

天机 video.length > 0 判断

visuddhinanda 2 år sedan
förälder
incheckning
9295bd90e8
1 ändrade filer med 4 tillägg och 1 borttagningar
  1. 4 1
      dashboard/src/components/template/Wbw/WbwVideoButton.tsx

+ 4 - 1
dashboard/src/components/template/Wbw/WbwVideoButton.tsx

@@ -19,6 +19,9 @@ const WbwVideoButtonWidget = ({ video }: IWidget) => {
   const [curr, setCurr] = useState(0);
 
   useEffect(() => {
+    if (!video || video.length === 0) {
+      return;
+    }
     const url = `/v2/attachment/${video[curr].videoId}`;
     console.info("url", url);
     get<IAttachmentResponse>(url).then((json) => {
@@ -29,7 +32,7 @@ const WbwVideoButtonWidget = ({ video }: IWidget) => {
     });
   }, [curr, video]);
 
-  return video ? (
+  return video && video.length > 0 ? (
     <VideoModal src={url} type={video[0].type} trigger={<VideoIcon />} />
   ) : (
     <></>