lottie-player icon indicating copy to clipboard operation
lottie-player copied to clipboard

Error on VUE. (window is not defined)

Open msaifudeen opened this issue 2 years ago • 12 comments

Versions Using:

"@lottiefiles/vue-lottie-player": "^1.0.1" "@lottiefiles/lottie-player": "^1.0.4",

Error getting: image

msaifudeen avatar Dec 02 '21 14:12 msaifudeen

Hi @msaifudeen, If you're using "@lottiefiles/vue-lottie-player" you don't need to import "@lottiefiles/lottie-player". If you still want to keep the lottie-player dependancy, this issue should be fixed in version 1.5.2 of the lottie-player :-)

samuelOsborne avatar Dec 02 '21 14:12 samuelOsborne

@samuelOsborne The same window error happened in @lottiefiles/vue-lottie-player. Tested with various workarounds, but same issue is occurring.

msaifudeen avatar Dec 02 '21 15:12 msaifudeen

@msaifudeen Will look for a fix and update you

samuelOsborne avatar Dec 02 '21 15:12 samuelOsborne

Thank you for the quick update @samuelOsborne

msaifudeen avatar Dec 02 '21 15:12 msaifudeen

Hi @msaifudeen I assume you're using nuxt, have you followed these steps when using the vue-lottie-player?

  1. Create a folder called 'plugins' at the root of your project
  2. Create a file named 'lottie-vue-player.client.js' inside the 'plugins' directory
  3. Inside this file put :
import Vue from 'vue';

import LottieVuePlayer from "@lottiefiles/vue-lottie-player";

Vue.use(LottieVuePlayer);
  1. in nuxt.config.js :
  plugins: [
    "~/plugins/lottie-vue-player.client.js"
  ],

You should then be able to use the element inside your templates

samuelOsborne avatar Dec 02 '21 16:12 samuelOsborne

Seen this solution early, But not using NUXT.

msaifudeen avatar Dec 02 '21 17:12 msaifudeen

Are you only using vuejs?

samuelOsborne avatar Dec 02 '21 18:12 samuelOsborne

Hi @msaifudeen , I haven't managed to re-create your error. Please note that for the moment lottie-vue-player only supports Vue 2 and not Vue 3. Heres the steps I took to get it running on Vue 2 :

  1. My main.js looks like this:
import Vue from 'vue'
import App from './App.vue'
import LottieVuePlayer from "@lottiefiles/vue-lottie-player";

Vue.use(LottieVuePlayer);
Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')
  1. In my .vue file I can then:

<template>
    <lottie-vue-player :src="`https://assets10.lottiefiles.com/packages/lf20_tzjfwgud.json`"
                       :player-controls="true"
                       style="width: 100%; height:400px">
    </lottie-vue-player>
</template>

samuelOsborne avatar Dec 03 '21 09:12 samuelOsborne

Added codes same as in the git doc in main.js, but window not defined error was occurring. Directly imported in the component, got async component related error.

msaifudeen avatar Dec 03 '21 15:12 msaifudeen

@msaifudeen Can you share snippets of implementation code? Or if you manage to reproduce it on a codesandbox that'd be a great help.

samuelOsborne avatar Dec 03 '21 15:12 samuelOsborne

the same happens to me, I'm using next.js

iAkashPattnaik avatar Mar 21 '23 08:03 iAkashPattnaik

Hi !

I have the same error but with Angular (17)

BugProg avatar Nov 15 '23 13:11 BugProg