From b70df22f0c33d829b20f887986a9028a244681dd Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 12 Apr 2022 12:44:46 +0800 Subject: [PATCH] =?UTF-8?q?effect=E6=B1=A1=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index c2fe6c3c..0267571a 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -11,6 +11,7 @@ import { NotionRenderer } from 'react-notion-x' import mediumZoom from 'medium-zoom' import { useEffect, useRef } from 'react' import dynamic from 'next/dynamic' +import { useRouter } from 'next/router' const Code = dynamic(() => import('react-notion-x/build/third-party/code').then((m) => m.Code) @@ -43,6 +44,8 @@ const NotionPage = ({ post }) => { }) const zoomRef = useRef(zoom ? zoom.clone() : null) + const router = useRouter() + useEffect(() => { // 将所有container下的所有图片添加medium-zoom const container = document?.getElementById('container') @@ -52,7 +55,7 @@ const NotionPage = ({ post }) => { (zoomRef.current).attach(imgList[i]) } } - }) + }, [router.events]) return