lazy loading in vue js code example
Example 1: vue js lazy load component
const Foo = () => import('./Foo.vue')
const router = new VueRouter({
routes: [{ path: '/foo', component: Foo }]
})
Example 2: Lazy loading and code splitting in Vue.js
<template>
<div>
<lazy-component />
</div>
</template>
<script>
const lazyComponent = () => import('Component.vue')
export default {
components: { lazyComponent }
}
export default {
components: {
lazyComponent: () => import('Component.vue')
}
}
</script>
Example 3: lazy loading by scroll vue
npm i vue-infinite-loading