mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-09 03:03:18 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
f6ba2255e6
commit
1e16b4a088
@ -1,14 +1,14 @@
|
||||
import { defineComponent, h, ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import type { Component, Ref } from "vue"
|
||||
import { defineComponent, h, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import type { Component, Ref } from 'vue'
|
||||
import ClientOnly from '#app/components/client-only'
|
||||
import { useObserver } from "#app/utils"
|
||||
import { useObserver } from '#app/utils'
|
||||
|
||||
export const createLazyIOClientPage = (componentLoader: Component) => {
|
||||
return defineComponent({
|
||||
inheritAttrs: false,
|
||||
setup (_, { attrs }) {
|
||||
const isIntersecting = ref(false);
|
||||
const el: Ref<Element | null> = ref(null);
|
||||
const isIntersecting = ref(false)
|
||||
const el: Ref<Element | null> = ref(null)
|
||||
let unobserve: (() => void) | null = null
|
||||
onMounted(() => {
|
||||
const observer = useObserver()
|
||||
@ -17,7 +17,7 @@ export const createLazyIOClientPage = (componentLoader: Component) => {
|
||||
unobserve?.()
|
||||
unobserve = null
|
||||
})
|
||||
});
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
unobserve?.()
|
||||
unobserve = null
|
||||
@ -26,13 +26,13 @@ export const createLazyIOClientPage = (componentLoader: Component) => {
|
||||
h(ClientOnly, undefined, {
|
||||
default: () => {
|
||||
if (isIntersecting.value) {
|
||||
return h(componentLoader, attrs);
|
||||
return h(componentLoader, attrs)
|
||||
} else {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
}
|
||||
})
|
||||
]);
|
||||
])
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user