话不多说,上代码,仅做记录!
第一步:
npm install vue-event-calendar --save
第二步:
import 'vue-event-calendar/dist/style.css'
import vueEventCalendar from 'vue-event-calendar'
Vue.use(vueEventCalendar, {locale: 'en'})
第三步:
<template>
<div class="hello">
<vue-event-calendar :events="demoEvents" @day-changed="handleDayChanged" @month-changed="handleMonthChanged"></vue-event-calendar>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
demoEvents: [{
date: '2016/11/12', // Required
title: 'Foo' // Required
}, {
date: '2016/12/15',
title: 'Bar',
desc: 'description',
customClass: 'disabled highlight' // Custom classes to an calendar cell
}]
}
},
methods:{
handleDayChanged(data){
console.log(data);
},
handleMonthChanged(data){
console.log(data);
}
}
}
</script>
<style scoped>
</style>
页面显示效果如下: