vue-event-calendar

vue-event-calendar

vue-event-calendar是一款简单小巧的事件日历组件,针对Vue2开发。样式美观,且响应式。 在线例子javascript

npm version

依赖

  • 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)。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>

API

// 下个月
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
本站公众号
   欢迎关注本站公众号,获取更多信息