Home » vue » Failed to mount component – using vue-airbnb-style-datepicker

Failed to mount component – using vue-airbnb-style-datepicker

Posted by: admin November 26, 2021 Leave a comment

Questions:

Trying vue-airbnb-style-datepicker

imported in my file.vue:

import AirbnbStyleDatepicker from 'vue-airbnb-style-datepicker'
import format from 'date-fns/format'

export default {
  components: {
    AirbnbStyleDatepicker
  }
}

enter image description here

But i’m getting an error: Failed to mount component: template or render function not defined.

Versions in package.json:

"date-fns": "^1.29.0",
"vue": "^2.5.2",
"vue-airbnb-style-datepicker": "^1.11.4",

Error:

enter image description here

Answers:

It will work if you follow installation guide and register it globally:

import Vue from 'vue'
import App from './App.vue'

// import component and stylesheet
import AirbnbStyleDatepicker from 'vue-airbnb-style-datepicker'
import 'vue-airbnb-style-datepicker/dist/styles.css'

// see docs for available options
const datepickerOptions = {}

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

https://mikaeledebro.gitbooks.io/vue-airbnb-style-datepicker/INSTALLATION.html#enable-plugin