1 | initial version |
To incorporate the dotlottie
package into Nuxt3, follow these steps:
npm install dotlottie
or
yarn add dotlottie
Create a new plugin file in the plugins
directory of your Nuxt3 project. For example, create a file called dotlottie.js
.
In the dotlottie.js
file, import the dotlottie
package and register it as a global plugin:
import { createApp } from 'vue'
import { Lottie } from 'dotlottie'
export default async function app({ app }) {
app.use(Lottie)
}
nuxt.config.js
file, add the dotlottie
plugin:export default {
plugins: [
'~/plugins/dotlottie.js'
]
}
Lottie
component in any of your Vue files:<template>
<div>
<Lottie :src="animation" :options="options" />
</div>
</template>
<script>
export default {
data() {
return {
animation: 'path/to/animation.lrjson',
options: {
loop: true,
autoplay: true,
path: 'path/to/player/'
}
}
}
}
</script>
That's it! You can now use dotlottie
to add Lottie animations to your Nuxt3 project.