vue-event-calendar
vue-event-calendar是一款簡單小巧的事件日歷組件,針對Vue2開發(fā)墙杯。樣式美觀蛾坯,且響應(yīng)式。
在線例子
依賴
- 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所有數(shù)據(jù) -->
{{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
開發(fā)
可以在github直接clone我的項目然后執(zhí)行如下命令繼續(xù)二次開發(fā)或發(fā)版俩由,歡迎star&&issue
npm run dev //develop
npm run build //production