vue-event-calendar-v2
Version:
A simple calendar to mark events for Vue2
161 lines (129 loc) • 4 kB
Markdown
> A simple events calendar for Vue2, no dependencies except Vue2. responsive & mobile first.
> [Live Demo Here](http://geoffzhu.cn/vue-event-calendar-v2/)

[](https://www.npmjs.com/package/vue-event-calendar-v2)
[中文文档](https://github.com/GeoffZhu/vue-event-calendar-v2/blob/master/README.zh.md)
- vue: ^2.0.0
``` sh
npm install vue-event-calendar-v2 --save
```
```javascript
import 'vue-event-calendar-v2/dist/style.css' //^1.1.10, CSS has been extracted as one file, so you can easily update it.
import vueEventCalendar from 'vue-event-calendar-v2'
// locale can be 'zh' , 'en' , 'es', 'pt-br', 'ja', 'ko', 'fr', 'it', 'ru', 'de', 'vi', 'ua', 'no, 'no-nn'
Vue.use(vueEventCalendar, {locale: 'en'})
```
```vue
<template>
<vue-event-calendar-v2 :events="demoEvents"></vue-event-calendar-v2>
</template>
<script>
export default {
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
}]
}
}
}
</script>
```
```vue
<template>
<vue-event-calendar-v2 :title="title" :events="demoEvents" @dayChanged="handleDayChange"></vue-event-calendar-v2>
</template>
```
In most cases, the default date string is enough,but when you want a custom date title, you can give a prop ```title```.
It is important to noticed that the title will be replaced with a static String you passed in. You need to monitor the dayChanged event and change the title by youself.
If you want customization event template. required Vue: ^2.1.0. Because I use new feature(Scoped Slots) of ^2.1.0
```vue
<template>
<vue-event-calendar-v2 :events="demoEvents">
<template scope="props">
<div v-for="(event, index) in props.showEvents" class="event-item">
<!-- In here do whatever you want, make you owner event template -->
{{event}}
</div>
</template>
</vue-event-calendar-v2>
</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>
```
Can handle two Events, @day-changed and @month-changed, callback params like ``` {date: '2017/06/23', events: []} ```.
```javascript
<template>
<vue-event-calendar-v2
:events="demoEvents"
@day-changed="handleDayChanged"
@month-changed="handleMonthChanged">
</vue-event-calendar-v2>
</template>
```
```
// When Vue.use, options
{
locale: 'en',
color: 'black', //Set main color
className: 'Custom className for current clicked date', // (default: 'selected-day')
weekStartOn: 'week Start on which day' // Can be: 1, 2, 3, 4, 5, 6, 0 (default: 0)
}
```
```javascript
// NextMonth
this.$EventCalendar.nextMonth()
```
```javascript
// PreMonth
this.$EventCalendar.preMonth()
```
```javascript
//ToDate
this.$EventCalendar.toDate('2016/11/12')
```
More in [Demo Folder](https://github.com/GeoffZhu/vue-event-calendar-v2/tree/master/demo)
```
npm run dev //develop
npm run build //production
```
- Remove today background, use a small dot below the date
- Increase the selected date style
- Add week start on
[](https://opensource.org/licenses/MIT)