Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document is not defined #26

Open
gomezmark opened this issue May 30, 2018 · 8 comments
Open

document is not defined #26

gomezmark opened this issue May 30, 2018 · 8 comments

Comments

@gomezmark
Copy link

I'm trying to use this on Nuxt.js
But Im having document is not defined.

import Vue from 'vue';
import {DateRange} from 'vue-date-range';

Vue.use(DateRange);

nuxt.config.js

 { src : '~/plugins/vue-date-range', ssr : false},

Thanks!

@ParadeTo
Copy link
Owner

Can you give a full code?

@gomezmark
Copy link
Author

@ParadeTo

plugins/vue-date-range.js

import Vue from 'vue';
import DateRange from 'vue-date-range';

Vue.use(DateRange);

nuxt.config.js

plugins : [ { src : '~/plugins/vue-date-range', ssr : false} ]

index.vue

<template>
 <div>
  <date-range  class="calendar" v-model="range" :lang="lang" @change="onChange"></date-range>
 </div>
</template>

<script>
 export default {
    data() {
     range: {
          startDate: Vue.moment(),
          endDate: Vue.moment().add(7, 'days')
        },
     lang : "en",
   },
  methods : {
    onChange(range) {
        this.range = range;
      },
      setRange (p) {
        if (typeof p === 'number') {
          console.log(p)
          this.range = {
            startDate: moment().add(p, 'days'),
            endDate: moment()
          }
        }
      }
  }
</script>

Thanks for the reply Sir

@ParadeTo
Copy link
Owner

Can you give a repository so that I can run it in my computer directly?

@ParadeTo
Copy link
Owner

I am afraid it is your project's problem, not the vue-date-range.

@ghost
Copy link

ghost commented Jun 13, 2018

Had the same problem, but importing plugin globally with no-ssr helped. Maybe try wrapping this <date-range class="calendar" v-model="range" :lang="lang" @change="onChange"></date-range> with<no-ssr> To author: please try running the component in nuxt project.

@gomezmark
Copy link
Author

@profispojka

I set the config to ssr : false?
is that correct?

@gomezmark
Copy link
Author

@ParadeTo

I'm trying to figure out I'm looking a work around.
I let you know if it worked.

Thanks

@ParadeTo
Copy link
Owner

@profispojka @gomezmark Sorry, I have not used nuxt before. Hope you can help to solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants