From c569b29d52882f372f268738bc37a464b8097a80 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 6 May 2022 17:52:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 9bf0c027..29fe3bed 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -40,7 +40,6 @@ const NotionPage = ({ post }) => { }, []) setTimeout(() => { // 将相册gallery下的图片加入放大功能 - // const container = document?.getElementById('container') const imgList = document?.querySelectorAll('.notion-collection-card-cover img') if (imgList && zoomRef.current) { for (let i = 0; i < imgList.length; i++) { @@ -48,7 +47,7 @@ const NotionPage = ({ post }) => { } } - const cards = document.getElementsByClassName('notion-collection-card') + const cards = document?.getElementsByClassName('notion-collection-card') for (const e of cards) { e.removeAttribute('href') } @@ -74,7 +73,7 @@ const NotionPage = ({ post }) => { */ function addWatch4Dom(element) { // 选择需要观察变动的节点 - const targetNode = element || document.getElementById('container') + const targetNode = element || document?.getElementById('container') // 观察器的配置(需要观察什么变动) const config = { attributes: true,