question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use with NUXT?

See original GitHub issue

Trying to figure out how to use this with NUXT. The default vue setup will not work because it does not support server side rendering. I would expect to be able to call this via a plugin and have tried a few different ways such as below:

Created a new plugin FullCalendarVue.js:

import Vue from 'vue';
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'

// Vue.use(FullCalendar);
Vue.component('FullCalendar', FullCalendar);
// Vue.component('dayGridPlugin', dayGridPlugin);
Vue.use(dayGridPlugin);

Added the plugin to nuxt.config.js:

  plugins: [
    {mode: 'client', src: '~/plugins/FullCalendarVue'},
  ],

On the vue page I wrap the calendar component in no-ssr tags:

<no-ssr>
        <FullCalendar
            defaultView="dayGridMonth"
            :plugins="calendarPlugins"
        />
</no-ssr>

This seems to load the fullcalendar plugin but I keep getting errors that “dayGridPlugin is not defined”. Any suggestions on how to setup?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:17

github_iconTop GitHub Comments

34reactions
stellasoft-georgecommented, Apr 17, 2019

@RMFogarty @nucle

Hope this helps you, this is how I got it working with nuxt:

  1. Create a base component, mine is at components/Calendar.vue and contains the following (copied from the full calendar documentation)
<template>
    <FullCalendar defaultView="dayGridMonth" :plugins="calendarPlugins" />
</template>

<script>
    import FullCalendar from '@fullcalendar/vue'
    import dayGridPlugin from '@fullcalendar/daygrid'

    export default {
        components: {
            FullCalendar // make the <FullCalendar> tag available
        },
        data() {
            return {
                calendarPlugins: [ dayGridPlugin ]
            }
        }
    }
</script>
  1. In a plugin at plugins/full-calendar.js I have the following
import Vue from 'vue';
import Calendar from '~/components/calendar'

Vue.component('full-calendar', Calendar);
  1. And then my nuxt.config.js has the following
plugins: [{src: '~/plugins/full-calendar', ssr: false}],

The above works for me in universal mode. Defining a base component is what full calendar recommend in the docs so I’ve done that, and ssr: false seems to be the key to avoid Element is not defined errors

5reactions
EstebanFuentealbacommented, Sep 30, 2019

Hello Guys, I’m experiencing “Element is not defined” errors. I tried ur steps @stellasoft-george . What do u think i’m missing ? I was trying to import the Calendar.vue component in another .vue file.

I am having the same issue, not sure how to fix it, even following @stellasoft-george solution

EDIT: solved the issue myself, got wrong direction when implementing following @stellasoft-george, it works now, thanks 😃

@chrno1209 you can implement

<template>
      <Calendar />
</template>
<script>
let components = {};
if(process.browser) {
    const Calendar = require('~/components/Calendar').default;
    components = {
        Calendar
    }
}
export default {
 components 
}
</script>
<style lang='scss'>
@import '~@fullcalendar/core/main.css';
@import '~@fullcalendar/daygrid/main.css';
</style>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt - The Intuitive Vue Framework
Build your next Vue.js application with confidence using Nuxt. An open source framework making web development simple and powerful.
Read more >
Free Nuxt.js Tutorial — Vue Mastery Course - Medium
In this Nuxt tutorial, a free lesson from the Vue Mastery course, we'll build an application together and learn about the folder structure ......
Read more >
Getting Started With Nuxt - Smashing Magazine
“Nuxt is a progressive framework based on Vue.js to create modern web applications. It is based on Vue.js official libraries (vue, vue-router ...
Read more >
What is Nuxt.js? - Vue School
Nuxt.js is a framework for creating Vue.js applications. Its goal is to help Vue developers take advantage of top-notch technologies, fast, easy and...
Read more >
What Is Nuxt.js? Learn More About the Intuitive Vue Framework
Nuxt.js works the same way a server-side framework works when a user visits a website. If server-side rendering is enabled, the requests are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found