广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >vue的h5日历组件实现详解
  • 672
分享到

vue的h5日历组件实现详解

2024-04-02 19:04:59 672人浏览 八月长安
摘要

本文实例为大家分享了Vue的h5日历组件实现代码,供大家参考,具体内容如下 日历样式自定义 日历组件 <template>   <section class="

本文实例为大家分享了Vue的h5日历组件实现代码,供大家参考,具体内容如下

日历样式自定义

日历组件

<template>
  <section class="wh_container">
    <div class="wh_content_all">
      <div class="wh_top_changge">
        <li @click="PreMonth(myDate,false)">
          <div class="wh_jiantou1"></div>
        </li>
        <li class="wh_content_li">{{dateTop}}</li>
        <li @click="NextMonth(myDate,false)">
          <div class="wh_jiantou2"></div>
        </li>
      </div>
      <div class="wh_content">
        <div class="wh_content_item" v-for="(tag,index) in textTop" :key="index">
          <div class="wh_top_tag">{{tag}}</div>
        </div>
      </div>
      <div class="wh_content">
        <div
          class="wh_content_item"
          v-for="(item,index) in list"
          @click="clickDay(item,index)"
          :key="index"
        >
          <!-- <div
            class="wh_item_date"
            :class="item.isToday?'wh_isToday':item.isPreDay?'wh_chose_day':item.isChosedDay?'wh_chose_day':''"
          >{{item.id}}</div>-->
          <div
            class="wh_item_date"
            v-bind:class="[{ wh_isMark: item.isMark},
            {wh_other_dayhide:item.otherMonth!=='nowMonth'},
            {wh_want_dayhide:item.dayHide},
            {wh_isToday:item.isToday},
            {wh_chose_day:item.chooseDay},setClass(item)]"
          >{{item.id}}</div>
        </div>
      </div>
    </div>
  </section>
</template>
<script>
import moment from "moment";
import timeUtil from "./calendar";
import Vue from "vue";
export default {
  data() {
    return {
      myDate: [],
      list: [],
      historyChose: [],
      dateTop: "",
    };
  },
  props: {
    rangeDate: {
      type: Array,
      default: () => [],
    },
    markDate: {
      type: Array,
      default: () => [],
    },
    markDateMore: {
      type: Array,
      default: () => [],
    },
    textTop: {
      type: Array,
      default: () => ["一", "二", "三", "四", "五", "六", "日"],
    },
    sundayStart: {
      type: Boolean,
      default: () => false,
    },
    aGoDayHide: {
      type: String,
      default: `0`,
    },
    futureDayHide: {
      type: String,
      default: `2554387200`,
    },
  },
  created() {
    this.intStart();
    // 获取今日的日期

    var curDate = new Date();
    var preDate = Date.parse(new Date(curDate.getTime() - 24 * 60 * 60 * 1000)); //前一天
    this.myDate = new Date(preDate);
    console.log(this.rangeDate);
  },
  methods: {
    intStart() {
      timeUtil.sundayStart = this.sundayStart;
    },
    setClass(data) {
      // console.log('data',data)
      let obj = {};
      obj[data.markClassName] = data.markClassName;
      return obj;
    },
    // 点击选择的日期
    clickDay: function (item, index) {
      console.log("in", "kkkkkk", item);

      if (item.otherMonth === "nowMonth" && !item.dayHide) {
        console.log("in", "kkkkkk");
        this.getList(this.myDate, item.date);
      }
      if (item.otherMonth !== "nowMonth") {
        item.otherMonth === "preMonth"
          ? this.PreMonth(item.date)
          : this.NextMonth(item.date);
      }
    },
    // 选择月份
    ChoseMonth: function (date, isChosedDay = true) {
      date = timeUtil.dateFORMat(date);
      this.myDate = new Date(date);
      this.$emit("changeMonth", timeUtil.dateFormat(this.myDate));
      if (isChosedDay) {
        this.getList(this.myDate, date, isChosedDay);
      } else {
        this.getList(this.myDate);
      }
    },
    // 上一个月的切换
    PreMonth: function (date, isChosedDay = true) {
      date = timeUtil.dateFormat(date);
      this.myDate = timeUtil.getOtherMonth(this.myDate, "preMonth");
      this.$emit("changeMonth", timeUtil.dateFormat(this.myDate));
      if (isChosedDay) {
        this.getList(this.myDate, date, isChosedDay);
      } else {
        this.getList(this.myDate);
      }
    },
    // 下一个月的切换
    NextMonth: function (date, isChosedDay = true) {
      date = timeUtil.dateFormat(date);
      this.myDate = timeUtil.getOtherMonth(this.myDate, "nextMonth");
      this.$emit("changeMonth", timeUtil.dateFormat(this.myDate));
      if (isChosedDay) {
        this.getList(this.myDate, date, isChosedDay);
      } else {
        this.getList(this.myDate);
      }
    },
    // 数据格式化的处理
    forMatArgs: function () {
      let markDate = this.markDate;
      let markDateMore = this.markDateMore;
      let rangeDate = this.rangeDate;
      markDate = markDate.map((k) => {
        return timeUtil.dateFormat(k);
      });
      rangeDate = rangeDate.map((k) => {
        return timeUtil.dateFormat(k);
      });
      return [markDate, markDateMore, rangeDate];
    },
    // 日期表格的的样式初始化
    getList: function (date, chooseDay, isChosedDay = true) {
      console.log(date, chooseDay, "listCanshu", this.rangeDate);
      const [markDate, markDateMore, rangeDate] = this.forMatArgs(); // 标签
      this.dateTop = `${date.getFullYear()}年${date.getMonth() + 1}月`; // 顶部的头
      let arr = timeUtil.getMonthList(this.myDate); // 获取当前日期的整个月份
      for (let i = 0; i < arr.length; i++) {
        let markClassName = "";
        let k = arr[i];
        k.chooseDay = false;
        const nowTime = k.date; //当前遍历的哪个时间
        const t = new Date(nowTime).getTime() / 1000;
        //看每一天的class
        for (const c of markDateMore) {
          if (c.date === nowTime) {
            markClassName = c.className || "";
          }
        }
        //标记选中某些天 设置class
        k.markClassName = markClassName;
        k.isMark = markDate.indexOf(nowTime) > -1;
        if (this.rangeDate) {
          k.isMark = rangeDate.indexOf(nowTime) > -1;
        }
        //无法选中某天
        k.dayHide = t < this.agoDayHide || t > this.futureDayHide;
        if (k.isToday) {
          this.$emit("isToday", nowTime);
        }

        // if(this.rangeDate.length){
        //   if(timeUtil.dateFormat(moment(this.rangeDate[0]).format("YYYY-MM-DD"))===nowTime || timeUtil.dateFormat(moment(this.rangeDate[6]).format("YYYY-MM-DD"))===nowTime){
        //     k.chooseDay = true;
        //   }else{
        //      k.chooseDay =  false;
        //   }
        // }
        var curDate = new Date();
        var preDate = Date.parse(
          new Date(curDate.getTime() - 24 * 60 * 60 * 1000)
        ); //前一天
        const preDay = timeUtil.dateFormat(
          moment(preDate).format("YYYY-MM-DD")
        );
        // 处理默认当月的的前一天是被选中
        if (nowTime === preDay && !chooseDay && !this.rangeDate.length) {
          k.chooseDay = true;
        } else {
          k.chooseDay = false;
        }

        let flag = !k.dayHide && k.otherMonth === "nowMonth";
        if (chooseDay && chooseDay === nowTime && flag) {
          this.$emit("choseDay", nowTime);
          this.historyChose.push(nowTime);
          console.log(this.historyChose);
          if (this.rangeDate.length) {
            k.chooseDay = false;
          } else {
            k.chooseDay = true;
          }
        } else if (
          this.historyChose[this.historyChose.length - 1] === nowTime &&
          !chooseDay &&
          flag
        ) {
          console.log("进来这里了");
          // 处理日月的切换
          if (this.rangeDate.length) {
            k.chooseDay = false;
          } else {
            if (this.chooseDay) {
              k.chooseDay = true;
            } else {
              k.chooseDay = false;
            }
          }
        }
      }
      this.list = arr;
    },
  },
  mounted() {
    this.getList(this.myDate);
  },
  watch: {
    rangeDate: {
      handler(val, oldVal) {
        this.getList(this.myDate);
      },
      deep: true,
    },
    markDate: {
      handler(val, oldVal) {
        this.getList(this.myDate);
      },
      deep: true,
    },
    markDateMore: {
      handler(val, oldVal) {
        this.getList(this.myDate);
      },
      deep: true,
    },
    agoDayHide: {
      handler(val, oldVal) {
        this.getList(this.myDate);
      },
      deep: true,
    },
    futureDayHide: {
      handler(val, oldVal) {
        this.getList(this.myDate);
      },
      deep: true,
    },
    sundayStart: {
      handler(val, oldVal) {
        this.intStart();
        this.getList(this.myDate);
      },
      deep: true,
    },
  },
};
</script>
<style scoped>
@media screen and (min-width: 460px) {
  .wh_item_date:hover {
    background: #00baff;
    cursor: pointer;
  }
}
* {
  margin: 0;
  padding: 0;
}

.wh_container {
  max-width: 410px;
  margin: auto;
}

li {
  list-style-type: none;
}
.wh_top_changge {
  display: flex;
}

.wh_top_changge li {
  cursor: pointer;
  display: flex;
  color: #040b29;
  font-size: 18px;
  flex: 1;
  justify-content: center;
  align-items: center;
  height: 47px;
}

.wh_top_changge .wh_content_li {
  cursor: auto;
  flex: 2.5;
}
.wh_content_all {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
  background-color: #ffffff;
  width: 100%;
  overflow: hidden;
  padding-bottom: 8px;
  border-radius: 10px;
}

.wh_content {
  display: flex;
  flex-wrap: wrap;
  padding: 0 3% 0 3%;
  width: 100%;
  justify-content: center;
}

.wh_content:first-child .wh_content_item_tag,
.wh_content:first-child .wh_content_item {
  color: #DDD;
  font-size: 16px;
}

.wh_content_item,
.wh_content_item_tag {
  font-size: 15px;
  width: 13.4%;
  text-align: center;
  color: #fff;
  position: relative;
}
.wh_content_item {
  height: 40px;
}

.wh_top_tag {
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #9b9da9;
}

.wh_item_date {
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #040b29;
}

.wh_jiantou1 {
  width: 12px;
  height: 12px;
  border-top: 2px solid #9b9da9;
  border-left: 2px solid #9b9da9;
  transform: rotate(-45deg);
}

.wh_jiantou1:active,
.wh_jiantou2:active {
  border-color: #040b29;
}

.wh_jiantou2 {
  width: 12px;
  height: 12px;
  border-top: 2px solid #9b9da9;
  border-right: 2px solid #9b9da9;
  transform: rotate(45deg);
}
.wh_content_item > .wh_isMark {
  margin: auto;
  
  background:rgba(235, 246, 255, 1);
  z-index: 2;
}
.wh_content_item .wh_other_dayhide {
  color: #bfbfbf;
}
.wh_content_item .wh_want_dayhide {
  color: #9b9da9;
}
.wh_content_item .wh_isToday {
  
  color: rgba(130, 183, 225, 1);
}
.wh_content_item .wh_pre_day {
  color: red;
}
.wh_content_item .wh_chose_day {
  background: rgba(168, 208, 240, 1);
  color: #fff;
  border-radius: 10px;
}
</style>

calendar.js 是生成月份盘,月数多少天的逻辑

import moment from "moment";
export default {
    // 当某月的天数
    getDaysInOneMonth(date) {
      const year = date.getFullYear();
      const month = date.getMonth() + 1;
      const d = new Date(year, month, 0);
      return d.getDate();
    },
    // 向前空几个
    getMonthweek(date) {
      const year = date.getFullYear();
      const month = date.getMonth() + 1;
      const dateFirstOne = new Date(year + '/' + month + '/1');
      return this.sundayStart ?
        dateFirstOne.getDay() == 0 ? 7 : dateFirstOne.getDay() :
        dateFirstOne.getDay() == 0 ? 6 : dateFirstOne.getDay() - 1;
    },
    
    getOtherMonth(date, str = 'nextMonth') {
      const timeArray = this.dateFormat(date).split('/');
      const year = timeArray[0];
      const month = timeArray[1];
      const day = timeArray[2];
      let year2 = year;
      let month2;
      if (str === 'nextMonth') {
        month2 = parseInt(month) + 1;
        if (month2 == 13) {
          year2 = parseInt(year2) + 1;
          month2 = 1;
        }
      } else {
        month2 = parseInt(month) - 1;
        if (month2 == 0) {
          year2 = parseInt(year2) - 1;
          month2 = 12;
        }
      }
      let day2 = day;
      const days2 = new Date(year2, month2, 0).getDate();
      if (day2 > days2) {
        day2 = days2;
      }
      if (month2 < 10) {
        month2 = '0' + month2;
      }
      if (day2 < 10) {
        day2 = '0' + day2;
      }
      const t2 = year2 + '/' + month2 + '/' + day2;
      return new Date(t2);
    },
    // 上个月末尾的一些日期
    getLeftArr(date) {
      const arr = [];
      const leftNum = this.getMonthweek(date);
      const num = this.getDaysInOneMonth(this.getOtherMonth(date, 'preMonth')) - leftNum + 1;
      const preDate = this.getOtherMonth(date, 'preMonth');
      // 上个月多少开始
      for (let i = 0; i < leftNum; i++) {
        const nowTime = preDate.getFullYear() + '/' + (preDate.getMonth() + 1) + '/' + (num + i);
        arr.push({
          id: num + i,
          date: nowTime,
          isToday: false,
          isPreDay:false,
          otherMonth: 'preMonth',
        });
      }
      return arr;
    },
    // 下个月末尾的一些日期
    getRightArr(date) {
      const arr = [];
      const nextDate = this.getOtherMonth(date, 'nextMonth');
      const leftLength = this.getDaysInOneMonth(date) + this.getMonthweek(date);
      const _length = 7 - leftLength % 7;
      for (let i = 0; i < _length; i++) {
        const nowTime = nextDate.getFullYear() + '/' + (nextDate.getMonth() + 1) + '/' + (i + 1);
        arr.push({
          id: i + 1,
          date: nowTime,
          isToday: false,
          isPreDay:false,
          otherMonth: 'nextMonth',
        });
      }
      return arr;
    },
    // format日期
    dateFormat(date) {
      date = typeof date === 'string' ? new Date(date.replace(/-/g, '/')) : date;
      return date.getFullYear() + '/' + (date.getMonth() + 1) + '/'
        + date.getDate();
    },
    // 获取某月的列表不包括上月和下月
    getMonthListNoOther(date) {
      const arr = [];
      const num = this.getDaysInOneMonth(date);
      const year = date.getFullYear();
      const month = date.getMonth() + 1;
      const toDay = this.dateFormat(new Date());
      console.log(toDay,'今日日期的格式化');
      var curDate = new Date();
      var preDate = Date.parse(new Date(curDate.getTime() - 24 * 60 * 60 * 1000)); //前一天
      const preDay = this.dateFormat(moment(preDate).format('YYYY-MM-DD'));
      console.log(preDay,'前一日日期的格式化');

      for (let i = 0; i < num; i++) {
        const nowTime = year + '/' + month + '/' + (i + 1);
        arr.push({
          id: i + 1,
          date: nowTime,
          isToday: toDay === nowTime,
          isPreDay: false,
          otherMonth: 'nowMonth',
        });
      }
      // console.log(arr,'月份日期')
      return arr;
    },
    
    // 获取某月的列表 用于渲染
    getMonthList(date) {
      return [ ...this.getLeftArr(date), ...this.getMonthListNoOther(date), ...this.getRightArr(date) ];
    },
    // 默认是周一开始
    sundayStart: false,
  };

组件的导出

// index.js

import CalendarDemo from './calendar.vue';
export default CalendarDemo;

组件的使用

<template>
  <div style="background-color:#F7F7F7;padding:0.43rem">
    <!-- <NewAppHeader title="行驶里程数据" :backGroundTrans="true" :hideGoback="true"> -->
      <NewAppHeader :title="DATA_FOREZEN.titleName[type]" :backGroundTrans="true" :hideGoback="true">
      <span class="d_left" @click="back"></span>
      <span class="d_right" @click="showModal('demo')"></span>
    </NewAppHeader>
    <div class="d_main" style="padding-top:1rem">
      <div class="v_tab">
        <div class="tab_general" :class="tab == 1 ? 'tab_active' : ''" @click="changeTab(1)">
          日
        </div>
        <div class="tab_general" :class="tab == 2 ? 'tab_active' : ''" @click="changeTab(2)">
          周
        </div>
      </div>
    </div>

    <div style="margin-top:0.45rem;">
      <div v-if="tab === 1">
        <CalendarDemo
          ref="Calendar"
          @change="handelChange"
          v-on:changeMonth="changeDate"
          :defaultDate="defaultDate"
          :futureDayHide="disableDay"
          :sundayStart="sundayStart"
          :textTop="textTop"
        ></CalendarDemo>
      </div>
      <div v-else>
        <CalendarDemo
          ref="Calendar"
          v-on:choseDay="clickDay"
          v-on:changeMonth="changeDate"
          :defaultDate="defaultDate"
          :futureDayHide="disableDay"
          :markDate="markDate"
          :rangeDate="rangeDate"
          :sundayStart="sundayStart"
          :textTop="textTop"
        ></CalendarDemo>
      </div>
    </div>


  </div>
</template>
<script>
import "@/utils/flexible.js";
const NewAppHeader = () => import("@/components/NewAppHeader");
import CalendarDemo from "./compnent/index";
import moment from "moment";
const DATA_FOREZEN = {
  titleName:{
    voice:'语音控制数据',
    switch:'远程车控数据',
    distance:'行驶里程数据'
  },
  noDataTip:{
    voice:'无语音控制数据',
    switch:'无远程车控数据',
    distance:'无行驶里程数据'
  },
  totoalTip:{
    voice:'累计控制',
    switch:'累计使用远程车控',
    distance:'累计行驶'
  },
  weekTotal:{
    voice:'累计语音控制',
    switch:'远程车控数据',
    distance:'累计行驶里程'
  },
  noteC:{
    voice:'每一段语音数据都有一段故事',
    switch:'新宝骏车控大玩家邀你来挑战',
    distance:'每一段行驶里程都有一段故事'
  },
  Company:{
    voice:'次',
    distance:'KM',
    switch:'次'
  },
  dateType:{
    1:'周',
    2:'周'
  },
  shareType:{
    1:'今日',
    2:'本周'
  }


}
export default {
  data() {
    return {
      DATA_FOREZEN,
      sundayStart: true,
      textTop: ["日", "一", "二", "三", "四", "五", "六"],
      isWeek: true,
      tab: 1,
      defaultDate: Date.parse(new Date()),
      disableDay: "",
      markDate: [],
      rangeDate: [],
      weekList: [
        { date: "1", num: "1" },
        { date: "2", num: "2" },
        { date: "3", num: "3" },
        { date: "4", num: "4" },
        { date: "5", num: "5" },
        { date: "6", num: "6" },
        { date: "7", num: "7" }
      ], //周里程的列表
      lastList: [],
    };
  },
  components: {
    CalendarDemo,
    NewAppHeader
  },
  filters: {
    filterDate(value) {
      return moment(value).format("MM月DD日");
    }
  },
  watch: {
    tab: {
      handler(val, oldVal) {
        console.log(val, oldVal);
        if (val == 2) {
          this.markDate = this.weekDay();
          this.rangeDate = this.weekDay();
          this.getData();
        }
      },
      deep: true
    }
  },
  created() {
    // 时间今日之前的时间不可选
    let today = moment().format("YYYY-MM-DD");
    this.disableDay = (moment(today).valueOf() / 1000).toString();
    // 处理前默认前一天的逻辑
    var curDate = new Date();
    var preDate = Date.parse(new Date(curDate.getTime() - 24 * 60 * 60 * 1000)); //前一天
    this.defaultDate = new Date(preDate);
    this.dateStr = moment(this.defaultDate).format("MM月DD日");
    // 获取行驶数据
    this.getData();
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    // 切换日月
    changeTab(arg) {
      this.tab = arg;
      this.getData();
    },
    weekDay(data) {
      if (data) {
        this.oToday = new Date(data);
      } else {
        this.oToday = new Date();
      }
      let defaultDay = 2;
      console.log(data,'data')
      this.currentDay = this.oToday.getDay();  // 获取当前周几
      console.log(this.currentDay,'currentDay ')
      if (this.currentDay == 0) {
        this.currentDay = 7;
      }
      let distansDay = this.currentDay - defaultDay;
      let mondayTime = this.oToday.getTime() - distansDay * 24 * 60 * 60 * 1000;
      let sundayTime = this.oToday.getTime() + (6 - this.currentDay) * 24 * 60 * 60 * 1000;
      let arr = [];
      for (let i = 0; i < 7; i++) {
        arr.push(
          moment(mondayTime)
            .add("days", i)
            .format("YYYY-MM-DD")
        );
      }
      console.log(arr)
      return arr;
    },
    // 子组件的返回参数
    clickDay(data) {
      console.log(data, "时间");
      if (this.tab == 2) {
        this.rangeDate = this.weekDay(data);
        this.getData();
      } else {
        this.defaultDate = data;
        this.dateStr = moment(data).format("MM月DD日");
        this.getData();
      }
    },
    // 接口数据请求
    getData() {
     // ... 省略啦
    },
    changeDate(data) {
      console.log(data); //左右点击切换月份
    },
  }
};
</script>
<style lang="less" scoped>
/deep/ .mint-header-title {
  font-size: 0.48rem;
  color: #040b29;
  background-color: rgb(247, 247, 247);
}
// /deep/ .new-mt-header.trans{
//    background-color: rgb(247, 247, 247);
// }
.d_left {
  position: fixed;
  padding: 0.25rem;
  top: 0.25rem;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  left: 0.43rem;
  height: 0.44rem;
  width: 0.25rem;
  display: inline-block;
  background-image: url("./../../imgs/vInternet/d_back.png");
}
.d_right {
  height: 0.5rem;
  width: 0.5rem;
  background-image: url("./../../imgs/vInternet/d_share.png");
  display: inline-block;
  background-repeat: no-repeat;
  margin-right: 0.2rem;
  margin-top: 0.35rem;
  background-size: 100%;
}
.d_main {
  display: flex;
  justify-content: center;
  align-items: center;
  .v_tab {
    height: 0.93rem;
    width: 3.73rem;
    border-radius: 0.53rem;
    color: #040b29;
    background-color: #ffffff;
    display: inherit;
    align-items: center;
    justify-content: center;
    font-size: 0.43rem;
    .tab_general {
      width: 1.87rem;
      border-radius: 0.53rem;
      height: 0.93rem;
      line-height: 0.93rem;
      text-align: center;
    }

    .tab_active {
      background: rgba(235, 246, 255, 1);
    }
  }
}
.d_note {
  height: 0.59rem;
  font-size: 0.51rem;
  font-family: Helvetica;
  color: rgba(4, 11, 41, 1);
  line-height: 0.59rem;
  margin: 0.41rem 0rem;
  font-style: italic;
    font-weight: 600;
}

}
</style>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程网。

--结束END--

本文标题: vue的h5日历组件实现详解

本文链接: https://www.lsjlt.com/news/166616.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • vue的h5日历组件实现详解
    本文实例为大家分享了vue的h5日历组件实现代码,供大家参考,具体内容如下 日历样式自定义 日历组件 <template>   <section class="...
    99+
    2022-11-13
  • vue实现日历组件
    基于VUE实现日历组件,供大家参考,具体内容如下 年和月份是使用输入框来切换的,没有做成选择框,⬅️和➡️切换月份,红色选取是选取的日期实现思路和网上的大多数一样,首先是把月份的天...
    99+
    2022-11-13
  • 如何实现vue日历组件
    这篇文章主要介绍了如何实现vue日历组件,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。1. 前言最近做项目遇到一个需求,需要制作一个定制化的日历组件(项目使用的UI框架不能满...
    99+
    2023-06-29
  • vue版日历组件的实现方法
    开发背景 常用日历组件可能满足不了我们自定义的多种需求(比如样式),因此通常情况下我们可能需要自己手动开发款日历,先上图 开发流程 1. 根据常用日历样式,我们template部分...
    99+
    2022-11-13
  • vue3.0实现考勤日历组件使用详解
    本文实例为大家分享了vue3.0实现考勤日历组件使用的具体代码,供大家参考,具体内容如下 自定义日历组件,首先我们要明确需求与面板展示内容 1、周日~周六。2、当前月日历1~(28...
    99+
    2022-11-13
  • Vue实现万年日历的示例详解
    目录前言1.日历的布局2.日期数据的产生3.年月的变化4.连续最长打卡日期5.补卡日期前言 又是一个老生常谈的功能,接下来会从零实现一个万年日历,从布局到逻辑,再到随处可见的打卡功能...
    99+
    2023-01-12
    Vue实现万年日历 Vue万年日历 Vue万年历
  • vue实现垂直无限滑动日历组件
    用vue做了一个垂直无限滑动日历,在这里记录一下实现。 效果 组件 verticalCalendar.vue <template>   <div ref="con...
    99+
    2022-11-13
  • vue日历组件的封装方法
    本文实例为大家分享了vue日历组件的封装代码,供大家参考,具体内容如下 图示 封装的组件的代码如下 <template>   <div class="calend...
    99+
    2022-11-13
  • Flutter 日历组件简单实现
    目录前言安装效果demo 演示业务使用 headerView使用配置属性DEMO感谢前言 近期有个业务需求,涉及用户付费相关的计算,需要一个日历组件,组件功能如下: 仅支持从明天开始...
    99+
    2022-11-13
    Flutter 日历组件 Flutter 日历
  • vue怎么实现垂直无限滑动日历组件
    这篇文章主要介绍“vue怎么实现垂直无限滑动日历组件”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“vue怎么实现垂直无限滑动日历组件”文章能帮助大家解决问题。效果组件verticalCalendar...
    99+
    2023-06-30
  • vue.js实现日历插件使用方法详解
    今天要实现的功能就是以下这个功能:vue.js模拟日历插件 好了废话不多说了 直接上代码了 css: *{ margin: 0; padding: 0;...
    99+
    2022-11-12
  • 详解怎么使用vue封装一个自定义日历组件
    执行这个方法之后,此时calendarProps的值为:4、根据日历属性生成日历日期的数据当我们已经知道本月第一天对应的周几索引值、本月一共有多少天和上个月一共有多少天这三个核心数据之后,就可以开始生成对应的日历数据了。思路如下:由于大部分...
    99+
    2023-05-14
    Vue.js 数据可视化 前端
  • 基于vue2实现一个日历组件
    目录QCalendar.scssgetRangeDay.jsformatTime.jsQCalendar.vue日历组件效果图日月年tips总结不用任何第三方库,只基于vue2实现一...
    99+
    2022-12-29
    vue日历组件 切换月周日都可选择 vue 日历 Vue 日程日历
  • Android自定义日历控件实例详解
    为什么要自定义控件 有时,原生控件不能满足我们对于外观和功能的需求,这时候可以自定义控件来定制外观或功能;有时,原生控件可以通过复杂的编码实现想要的功能,这时候可以自定义控件来...
    99+
    2022-06-06
    Android
  • vue自定义可选时间的日历组件
    本文实例为大家分享了vue自定义可选时间日历组件的具体代码,供大家参考,具体内容如下 日历功能: 1、过去时间不可选择 2、可自定义不可选时间 3、本月默认展示当天,其他月展示第一天...
    99+
    2022-11-12
  • vue可ctrl,shift多选,可添加标记日历组件详细
    目录一、 按照 "日", "一", "二", "三", "四", &qu...
    99+
    2022-11-13
  • Vue自定义日历小控件使用方法详解
    本文实例为大家分享了Vue自定义日历小控件的具体代码,供大家参考,具体内容如下 废话少说,先上效果图: 可以在效果图中看到,选择不同的月份的时候当月天数与星期几都是一一对应,非当月...
    99+
    2022-11-13
  • 基于Vue3实现日历组件的示例代码
    以下是一个基于 Vue 3 实现的简单日历组件的代码示例。这个日历组件包含了前一个月、当前月、下一个月的日期,并且可以支持选择日期、切换月份等功能。 <template>...
    99+
    2023-05-17
    Vue3实现日历组件 Vue3日历组件 Vue3日历 Vue 日历
  • vue实现钉钉的考勤日历
    本文实例为大家分享了vue实现钉钉的考勤日历的具体代码,供大家参考,具体内容如下 直接上效果图,需要再往下看 GitHub地址:vue-calendar-component 由于需...
    99+
    2022-11-12
  • vue中使用element日历组件的示例代码
    先看下效果图: 完整代码附上 <template> <div class="newSeeds" id="famerCalendar"> ...
    99+
    2022-11-12
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作