未知的自定义元素:<v-calendar>

时间:2019-08-28 21:02:29

标签: vue.js vue-component vuetify.js

尝试使用Vuetify的日历功能时出现错误。我可以编译所有内容,但这是我尝试渲染时得到的: 未知的自定义元素v日历-您是否正确注册了组件?

<template>
    <v-card style="margin:20px;">
        <v-calendar
            type="week"
            now="2019-01-08"
            value="2019-01-08"
            :events="events"
        ></v-calendar>
    </v-card>
</template>

<script>
    import Vue from 'vue'
    import moment from 'moment'
    import API from '@/mixins/API.js'
    import router from '@/router'
    import Vuetify, {VCalendar} from 'vuetify'
    import 'vuetify/dist/vuetify.min.css'

    Vue.use(Vuetify, {
        VCalendar
    });
    //some more code
</script>

1 个答案:

答案 0 :(得分:1)

您可能没有正确加载vuetify组件。尝试将以下代码添加到模板中:

<script>
import { VCalendar } from 'vuetify/lib'

export default {
    components: { VCalendar },
    ...
}
</script>

如果您不想每次都手动加载组件,也可以check out the vuetify-loader plugin来自动为您添加组件。