Usage with Nuxt 3
Register the component
- Create a folder called
pluginsat the root of your project. - Create a file named
Vue3Marquee.client.tsinside thepluginsdirectory. - Add the following code to the file;
import Vue3Marquee from 'vue3-marquee' export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.use(Vue3Marquee, { name: 'Vue3Marquee' }) }) - Import the css file required by the component into your
app.vuefile.<template> <NuxtLayout> <NuxtPage /> </NuxtLayout> </template> <script setup lang="ts"> import 'vue3-marquee/dist/style.css' // ... rest of your code </script>✨ Well done! This should register a global component that you can call anywhere in your app under the<Vue3Marquee>tag. You can also change the name of the component by changing thenameproperty in the plugin file.
Use the component
Now you can use the component anywhere in your app. Here is an example of how to use it in a page.
Using the
<client-only> tag might be needed to prevent any hydration errors.<template>
...
<Vue3Marquee>
<img height="200" width="300" src="...img" />
<img height="200" width="300" src="...img" />
<img height="200" width="300" src="...img" />
</Vue3Marquee>
...
</template>Table of Contents