vue日历组件

本文介绍了如何使用Vue.js框架创建一个功能完善的日历组件,包括日历的展示、日期选择、事件绑定等功能。通过实例代码解析,帮助读者理解Vue组件化开发的思想。
摘要由CSDN通过智能技术生成
<template>
  <div class="calendar">
    <div class="top">
      <p>
        <span @click="reduceYear"><<</span>
        <span @click="reduceMonth"><</span>
      </p>
      <p>{
  {year}}年{
  {conversion(month)}}月</p>
      <p>
        <span @click="addMonth">></span>
        <span @click="addYear">>></span>
      </p>
    </div>
    <ul class="week">
      <li v-for="(item,index) in weekList" :key="index">{
  {item}}</li>
    </ul>
    <ul>
      <li class="lastMonth" v-for="(item,index) in lastMonthDays" :key="index+31">
        <p>{
  {item}}</p>
        <p>{
  {month-1>0?toLunar(year, month-1, item):toLunar(year-1, 12, item)}}</p>
      </li>
      <li
        class="nowMonth"
        :class="{mark:item===markDay}"
        v-for="(item,index) in nowMonthDays"
        :key="index+62"
        @click="changeDay(item)"
      >
        <p>{
  {item}}</p>
        <p>{
  {toLunar(year, month, item)}}</p>
      </li>
      <li class="nextMonth" v-for="(item,index) in nextMonthDays" :key="index">
        <p>{
  {item}}</p>
        <p>{
  {toLunar(year, month+1, item)}}</p>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      year: null,
      month: null,
      day: null,
      markDay: null,
      weekList: ["日", "一", "二", "三", "四", "五", "六"],
      lastMonthDays: [],
      nowMonthDays: [],
  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值