krot

lazyComponent nuxt.js

May 25th, 2022 (edited)
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. https://nuxtjs.org/docs/directory-structure/components/#dynamic-imports
  2. <LazyMountainsList v-if="show" />
  3. <lazy-mountains-list v-if="show" />
  4. vue
  5.  
  6. <template>
  7.   <div>
  8.     <lazy-component />
  9.   </div>
  10. </template>
  11.  
  12. <script>
  13. const lazyComponent = () => import('Component.vue')
  14. export default {
  15.   components: { lazyComponent }
  16. }
  17.  
  18. // Another syntax
  19. export default {
  20.   components: {
  21.     lazyComponent: () => import('Component.vue')
  22.   }
  23. }
  24. </script>
Add Comment
Please, Sign In to add comment