Home > other >  Vue-cal error when importing in component
Vue-cal error when importing in component

Time:10-19

After install npm i vue-cal

and in my js file:

import VueCal from 'vue-cal'

I get this message in the console: Failed to resolve module specifier "vue-cal"

CodePudding user response:

Related to the Doc, Vue Cal is a component so you have to use it like a component.

You have to do something like that:

import VueCal from 'vue-cal'
import 'vue-cal/dist/vuecal.css'

export default {
  components: { VueCal },
  ...
}

Documentation https://antoniandre.github.io/vue-cal/

Still got error?

You can remove the import above and use a script, in the documentation above related to the section Or via tag.

In your file index.html inside the head tag:

<head>
  ...
  <script src="https://unpkg.com/vue@legacy"></script>
  <script src="https://unpkg.com/vue-cal@legacy"></script>
  <link href="https://unpkg.com/vue-cal@legacy/dist/vuecal.css" rel="stylesheet">
</head>

Now Vue cal is available overall in your vue app, you just have to go in your component and do that:

export default {
  components: { VueCal: vuecal },
}
  • Related