From c9e9a55ca744871ec7435b7e965e15a3f624954c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 09:46:08 +0800 Subject: [PATCH] =?UTF-8?q?bug:=E5=AF=86=E7=A0=81=E4=B8=80=E9=97=AA?= =?UTF-8?q?=E8=80=8C=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[slug].js | 4 ++-- pages/article/[slug].js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pages/[slug].js b/pages/[slug].js index 99f49fed..cabde864 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -19,9 +19,9 @@ const Slug = props => { } // 文章锁🔐 - const [lock, setLock] = useState(true) + const [lock, setLock] = useState(post.password && post.password !== '') useEffect(() => { - if (post && post.password && post.password !== '') { + if (post.password && post.password !== '') { setLock(true) } else { setLock(false) diff --git a/pages/article/[slug].js b/pages/article/[slug].js index aba79897..09259f7f 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -35,9 +35,10 @@ const Slug = props => { } // 文章锁🔐 - const [lock, setLock] = useState(true) + const [lock, setLock] = useState(post.password && post.password !== '') + console.log('lock 默认值', lock) useEffect(() => { - if (post && post.password && post.password !== '') { + if (post.password && post.password !== '') { setLock(true) } else { setLock(false)