10 months ago

Vue.components() vs Vue.use() and why I can't get calendar to work.

Posted 10 months ago by chrisgrim

Hi, I am trying to install the calendar. I am running into a bit of an issue on setup. Their instructions say to add

// make sure we can use it in our components
Vue.use(airbnbstyledatepicker, datepickerOptions)

to my app.js file. The issue is, I only learned about using

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

with the tutorials at laracasts. I have created a new component

Vue.component('airbnbstyledatepicker', require('./components/AirbnbStyleDatepicker.vue').default);

which does load but is super limited. This is all that is in the component for data and methods

data() {
    return {
      dateFormat: 'D MMM',
      dateOne: '',
      dateTwo: ''
  methods: {
    formatDates(dateOne, dateTwo) {
      let formattedDates = ''
      if (dateOne) {
        formattedDates = format(dateOne, this.dateFormat)
      if (dateTwo) {
        formattedDates += ' - ' + format(dateTwo, this.dateFormat)
      return formattedDates

In the installation it says all the info is loaded with the Vue.Use. However when I try to use

Vue.use(airbnbstyledatepicker, datepickerOptions)

I get the error AirBnbStyleDatepicker is not defined. Is this because I am not pointing to the right folder?

Please sign in or create an account to participate in this conversation.