vue-event-calendar
vue-event-calendar是一款简单小巧的事件日历组件,针对Vue2开发。样式美观,且响应式。
在线例子
依赖
- vue: ^2.0.0
使用方法
安装
npm install vue-event-calendar --save
入口 Main.js
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)。
自定义颜色
//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>
API
// 下个月
this.$EventCalendar.nextMonth()
// 上个月
this.$EventCalendar.preMonth()
//到指定日期
this.$EventCalendar.toDate('2016/11/12')
可以看我写的Demo
开发
可以在github直接clone我的项目然后执行如下命令继续二次开发或发版,欢迎star&&issue
npm run dev //develop
npm run build //production