From 0a18180c5222eee08f1ab87d46d78520e2b10b83 Mon Sep 17 00:00:00 2001 From: cn-2k <59366705+cn-2k@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:32:45 -0300 Subject: [PATCH] docs: adding nuxt 3 usage guide Adding how to use the lib with Nuxt 3 in the doc --- packages/vue-virtual-scroller/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/vue-virtual-scroller/README.md b/packages/vue-virtual-scroller/README.md index f978270a..6483c9e9 100644 --- a/packages/vue-virtual-scroller/README.md +++ b/packages/vue-virtual-scroller/README.md @@ -51,6 +51,30 @@ app.component('RecycleScroller', RecycleScroller) import 'vue-virtual-scroller/dist/vue-virtual-scroller.css' ``` +## Nuxt 3 + +In order to use with Nuxt 3 you can use a Nuxt plugin to do so. + +Create a ``plugins/`` folder and a file for the plugin, then paste the code below: + +```js +// virtualScroller.ts +import "vue-virtual-scroller/dist/vue-virtual-scroller.css"; +import { + DynamicScroller, + DynamicScrollerItem, + RecycleScroller, +} from "vue-virtual-scroller"; + +export default defineNuxtPlugin((nuxtApp) => { + nuxtApp.vueApp.component("RecycleScroller", RecycleScroller); + nuxtApp.vueApp.component("DynamicScroller", DynamicScroller); + nuxtApp.vueApp.component("DynamicScrollerItem", DynamicScrollerItem); +}); +``` + +Make sure to import only the components that you want in the plugin file (there's no need to import them in anywhere because Nuxt already does it for us). + ## Browser ```html