1.0.1 • Published 1 year ago

vue-mobcal3 v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vue-mobcal3

vue GitHub stars npm GitHub issues license

NPM

Example

image.png


Install

npm install vue-mobcal3 --save

# or
yarn add vue-mobcal3

Global Registration

import Vue from 'vue'
import VueMobCal from 'vue-mobcal3'

Vue.use(VueMobCal)

Local Registration

import { VueMobCal } from 'vue-mobcal3'

export default {
  components: {
    VueMobCal
  }
}

Usage

Basic Usage

<vue-mob-cal v-model:value="currentDate" v-model:mode="mode" color="#007873" />
import { VueMobCal } from 'vue-mobcal3';
import "vue-mobcal3/dist/index.css";
import { ref } from 'vue';

export default {
  setup() {
    const currentDate = ref(new Date());
    const mode = ref('month');
  }
}

Custom Slot

<vue-mob-cal v-model:value="currentDate" v-model:mode="mode">
  <template #left>
    <span>LeftBtn</span>
  </template>
  <template #right>
    <span>RightBtn</span>
  </template>
  <template #title>
    <span>Title</span>
  </template>
  <template #week="props">
    <span>周{{ week(props.day) }}</span>
  </template>
  <template #day="props">
    <span v-if="props.util.isToday(props.date)">今</span>
    <span v-else>{{ props.date.getDate() }}</span>
    <!-- A dot will appear at the bottom -->
    <span v-if="props.date.getDay() === 1" class="mindot" style="background-color: red;"></span>
    <span v-if="props.date.getDay() === 6" class="mindot"></span>
    <!-- If you want to display the background, you have to configure this -->
    <span class="dot"></span> 
  </template>
</vue-mob-cal>
import { ref } from 'vue'

export default {
  setup() {
    const currentDate = ref(new Date())
    const mode = ref('month')

    const week = (day) => {
      const days = ['一', '二', '三', '四', '五', '六', '日']
      day = day || 7
      return days[day - 1]
    }
  }
}

API

Props

AttributeDescriptionTypeDefault
v-model:valueCurrent calendar dateDatenew Date()
v-model:modeDisplay mode, support monthly or weekly display, params monthweekStringmonth
v-model:colorTheme colorString#007ad3

Slot

NameDescriptionSlotProps
titleCustom title { util: object }
weekCustom Week Title{ day: number } 0-6
leftCustom left icon-
rightCustom right icon-
dayCustom Calendar Item { date: date, util: object }
- utilCommon method{isToday: function, isWorkDay: function, isOtherMonth: function, isActiveDay: function, onPrev: function, onNext: function, onChangeMode: function}

Event

EventDescriptionArguments
onPrevChange to last month/week-
onNextChange to next month/week-
onChangeWhen the time is selected, it will be triggered and returns the Date() object of the selected time.-
onChangeModeToggles display mode or set display modemode:!string

CDN

<script src="https://cdn.jsdelivr.net/npm/vue@3.2.1/dist/vue.global.js"></script>
<script type="text/javascript" src="https://unpkg.com/vue-mobcal3/dist/vue-mobcal3.umd.js"></script>

<div id="app">
  <vue-mob-cal v-model:value="currentDate" v-model:mode="mode">
  </vue-mob-cal>
</div>
<script type="text/javascript">
  new Vue({
      el: '#app',
      data: {
          mode: 'month',
          currentDate: new Date()
      }
  })
</script>

Changelog

Detailed changes for each release are documented in the release notes.

License

MIT