From 3ae7b0091c8b78ee37fbb294d4036075ccb24a72 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Sun, 17 Apr 2022 17:16:48 +0800 Subject: [PATCH] fix: ssg window --- src/composables/helper.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/composables/helper.ts b/src/composables/helper.ts index 336fe23..8e8e589 100644 --- a/src/composables/helper.ts +++ b/src/composables/helper.ts @@ -1,4 +1,4 @@ -import { useElementBounding } from '@vueuse/core' +import { isClient, useElementBounding } from '@vueuse/core' import type { Ref } from 'vue' /** @@ -10,11 +10,12 @@ export function useInvisibleElement(target: Ref) { const { top } = useElementBounding(target) const isVisible = computed(() => { - return window.scrollY < top.value + return isClient ? window.scrollY < top.value : true }) const show = () => { - window.scrollTo(0, top.value) + if (isClient) + window.scrollTo(0, top.value) } return {