epic-spinners icon indicating copy to clipboard operation
epic-spinners copied to clipboard

Integrate epic-spinner in nuxtjs project

Open jeydi243 opened this issue 4 years ago • 7 comments

Hi everyone!

Can someone help me to integrate it in nuxtjs! Thank you!

jeydi243 avatar Aug 31 '20 11:08 jeydi243

I used nuxt with typescript, It is just simple as install and import

JS version should be the same

tokidoki11 avatar Nov 04 '20 09:11 tokidoki11

Doesn't appear to work -

<script lang="ts">
import Vue from 'vue';
import { AtomSpinner } from 'epic-spinners';

export default Vue.extend({
  components: {
    AtomSpinner,
  },
});
</script>

image

axieum avatar Jan 16 '21 05:01 axieum

You can do something like below.

<script>
let HollowDotsSpinner = null

if (process.client) {
  HollowDotsSpinner = require('epic-spinners').HollowDotsSpinner
}

export default Vue.extend({
  components: {
    HollowDotsSpinner,
  },
});
</script>

stevenferrer avatar Mar 01 '21 08:03 stevenferrer

I manage to solve this issue by registering the desired spinner component globally. I am using Nuxt.js v2 for reference.

  1. Create a plugin plugin/<filename>.js With the contents:
import Vue from 'vue'
import { <spinner> } from 'epic-spinners'

Vue.component(component_name, <spinner>) 
  1. Import the plugin on the plugins option in nuxt.config.js

mamaoag avatar Apr 20 '21 23:04 mamaoag

For Nuxt SSR, Just follow the usage example in the home page

  // To use minified css and js files instead of .vue single file components:
 import 'epic-spinners/dist/lib/epic-spinners.min.css'
 import {AtomSpinner} from 'epic-spinners/dist/lib/epic-spinners.min.js'

yauri-io avatar May 02 '21 09:05 yauri-io

I seem to be experiencing the same issue even after using the plugins workaround by @mamaoag. Also, no changes with the <client-only tag.

vinosamari avatar Mar 15 '22 08:03 vinosamari

I'm on nuxt 2.* with nuxt-bridge and this works totally fine for me (static build though):

import { OrbitSpinner } from 'epic-spinners';

export default {
  components: {
    OrbitSpinner,
  },
};

galaxyblur avatar Apr 05 '23 14:04 galaxyblur