vue3-lazy-load-component
Vue3 Lazy Component
Lazy render Vue component for other Vue components or any code.
This is an adaption of v-lazy-component for Vue 3.5+
Usage
Installation
yarn add vue3-lazy-load-component # or npm i vue3-lazy-load-component
Global Register
import { createApp } from 'vue'
import App from './App.vue'
import LazyComponent from 'vue3-lazy-load-component'
const app = createApp(App)
app.use(LazyComponent)
app.mount('#app')
Local Register
<script setup>
import LazyComponent from 'vue3-lazy-load-component'
</script>
Usage
<lazy-component wrapper-tag="section" @intersected="optionalDispatch">
<your-component/>
<!-- Optional -->
<template #placeholder>
<span>Loading...</span>
</template>
</lazy-component>
Props
| Name | Description | Type | Default |
|---|---|---|---|
wrapper-tag |
Html tag of lazy component | String | div |
root-margin |
Intersection Observer API doc | String | 0px 0px 0px 0px |
scroll-margin |
Intersection Observer API doc | String | 0px 0px 0px 0px |
threshold |
Intersection Observer API doc | Number, Array | 0 |
| See Intersection Observer API doc |
Slots
| Name | Description |
|---|---|
placeholder |
Content that is shown as a placeholder until it comes into view |
Events
| Name | Description |
|---|---|
intersected |
Dispatched when element becomes visible |
π License
MIT
Related Packages
duplicate-dependencies-webpack-plugin
webpack plugin to find duplicated dependencies from your bundle
332,104
6
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.1 | ^3.5.0 | MIT | |
| 1.0.0 | ^3.5.0 | MIT |