无法安装组件-使用vue-airbnb-style-datepicker

时间:2018-08-25 19:14:48

标签: vue.js datepicker vuejs2

尝试vue-airbnb-style-datepicker

导入到我的文件中。vue:

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

export default {
  components: {
    AirbnbStyleDatepicker
  }
}

enter image description here

但是我遇到了错误:Failed to mount component: template or render function not defined.

package.json中的版本:

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

错误:

enter image description here

1 个答案:

答案 0 :(得分:1)

如果您遵循安装指南并在全球范围内进行注册,它将起作用:

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