vue-event-calendar是一款简单小巧的事件日历组件,针对Vue2开发。样式美观,且响应式。 在线例子javascript
npm install vue-event-calendar --save
import vueEventCalendar from 'vue-event-calendar' Vue.use(vueEventCalendar, {locale: 'en'}) //locale can be 'zh' or 'en'
<template> <vue-event-calendar :events="demoEvents"></vue-event-calendar> </template> <script> export default { data () { return { demoEvents: [{ date: '2016/12/15', title: 'eat', desc: 'longlonglong description' },{ date: '2016/11/12', title: 'this is a title' }] } } } </script>
vue-event-calendar容许自定义事件模版,可是这个功能须要Vue 2.1.0版本以上才能够使用。缘由是我试用了2.1.0以上才有的新功能做用域插槽(Scoped Slots)。vue
//When Vue.use, you can give a color Vue.use(vueEventCalendar, {locale: 'en', color: '#4fc08d'})
<template> <vue-event-calendar :events="demoEvents"> <template scope="props"> <div v-for="(event, index) in props.showEvents" class="event-item"> <!-- 这里拿到的是传入的单个event全部数据 --> {{event}} </div> </template> </vue-event-calendar> </template> <script> export default { data () { return { demoEvents: [{ date: '2016/12/15', title: 'eat', desc: 'longlonglong description' },{ date: '2016/11/12', title: 'this is a title' }] } } } </script>
// 下个月 this.$EventCalendar.nextMonth()
// 上个月 this.$EventCalendar.preMonth()
//到指定日期 this.$EventCalendar.toDate('2016/11/12')
能够看我写的Demojava
能够在github直接clone个人项目而后执行以下命令继续二次开发或发版,欢迎star&&issuegit
npm run dev //develop npm run build //production