fix: ssg window

This commit is contained in:
YunYouJun
2022-04-17 17:16:48 +08:00
parent 3ae07a1073
commit 3ae7b0091c

View File

@@ -1,4 +1,4 @@
import { useElementBounding } from '@vueuse/core'
import { isClient, useElementBounding } from '@vueuse/core'
import type { Ref } from 'vue'
/**
@@ -10,10 +10,11 @@ export function useInvisibleElement(target: Ref<HTMLElement>) {
const { top } = useElementBounding(target)
const isVisible = computed(() => {
return window.scrollY < top.value
return isClient ? window.scrollY < top.value : true
})
const show = () => {
if (isClient)
window.scrollTo(0, top.value)
}