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