最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue自定義可以選擇日期區(qū)間段的日歷插件

 更新時(shí)間:2022年03月08日 14:28:10   作者:面壁思過程  
這篇文章主要為大家詳細(xì)介紹了Vue自定義可以選擇日期區(qū)間段的日歷插件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Vue自定義日歷插件的具體代碼,供大家參考,具體內(nèi)容如下

由于網(wǎng)上的插件沒有符合項(xiàng)目的需求決定自己實(shí)現(xiàn)

圖示如下:

默認(rèn)選擇今天的日期時(shí)間段

1.默認(rèn)狀態(tài)(默認(rèn)選擇當(dāng)前日期的時(shí)間段(藍(lán)底背景色代表選中時(shí)間段),

2.當(dāng)前日期之前的時(shí)間不可以選擇(禁用了點(diǎn)擊事件))

3.當(dāng)日歷上的操作的年份月份小于當(dāng)前時(shí)間的年份月份時(shí)禁止點(diǎn)擊上一月的按鈕

選中狀態(tài)

1.可以跨年分跨月份選擇

2.點(diǎn)擊取消按鈕時(shí)回復(fù)到默認(rèn)的選擇時(shí)間

代碼如下

<template>
? <div class="biji">
?
? ?<!-- <div>時(shí)間段:{{starttime}}至{{endtime}}</div> -->
?
? ? <div class="mobile-top">
? ? ? <div class="sel-time">
? ? ? ? <p>開始時(shí)間</p>
? ? ? ? <p class="start-date">{{starttime}}</p>
? ? ? </div>
? ? ? <div class="unsel-time">
? ? ? ? <p>結(jié)束時(shí)間</p>
? ? ? ? <p class="end-date">{{endtime==''?'請(qǐng)選擇結(jié)束日期':endtime}}</p>
? ? ? </div>
? ? </div>
?
? ? <div class="title">
? ? ? <div class="btn" @click="last()"?
? ? ? ?:class="(month<=nowmonth)&&(Year<=nowYear)?'noclick':'' ">上一月</div>
? ? ? <div class="text">{{Year}}年{{month}}月</div>
? ? ? <div class="btn" @click="next()">下一月</div>
? ? </div>
?
? ? <div class="head">
? ? ? <div class="days" v-for="(item,index) in ['星期日','星期一','星期二','星期三','星期四','星期五','星期六']" :key="index">
? ? ? ? {{item}}
? ? ? </div>
? ? </div>
?
? ? <div class="wrap">
? ? ? <div class="span" v-for="(item,index) in calendarList" :key="index" @click="click(item.count)" :class="item==''?'kong'
? ? ? :item.count<nowtime?'noclick'
? ? ? :(item.count>=starttime&&item.count<=endtime)||item.count==starttime?'active':''">
? ? ? ? {{item.value}}
? ? ? </div>
? ? </div>
?
? ? <div class="bottombtn">
? ? ? <button class="cancle-btn" @click='cancle()'>取消</button>
? ? ? <button class="sure-btn" @click='firm()'>確定</button>
? ? </div>
? </div>
</template>
?
<script>
? export default {
? ? name: 'Biji',
? ? data() {
? ? ? return {
? ? ? ? nowtime: '', //當(dāng)前日期的時(shí)間戳
?
? ? ? ? clickitem: 0, //點(diǎn)擊的時(shí)間戳
? ? ? ? clickcount: 0, //點(diǎn)擊次數(shù)
? ? ? ? starttime: '', //開始時(shí)間 數(shù)字 ? 默認(rèn)選中當(dāng)天日期
? ? ? ? endtime: '', //結(jié)束時(shí)間 數(shù)字
?
? ? ? ? Year: new Date().getFullYear(), ? //日歷上的年份
? ? ? ? month: new Date().getMonth() + 1, //日歷上的月份
? ? ? ? Day: new Date().getDate(), ? ? ? ?//日歷上的天份
?
? ? ? ? nowYear: new Date().getFullYear(),
? ? ? ? nowmonth: new Date().getMonth() + 1,
? ? ? ? nowDay: new Date().getDate(),
?
? ? ? ? calendarList: [],
? ? ? }
? ? },
? ? created() {
? ? ? this.Draw(this.nowYear, this.nowmonth);
?
? ? ? let time_month = this.nowmonth; //現(xiàn)在的月份
? ? ? let time_day = this.nowDay; //現(xiàn)在的天數(shù)
? ? ? if (this.nowmonth < 10) {
? ? ? ? time_month = 0 + '' + this.nowmonth;
? ? ? }
? ? ? if (this.nowDay < 10) {
? ? ? ? time_day = 0 + '' + this.nowDay;
? ? ? }
?
? ? ? this.nowtime = this.nowYear + '' + time_month + '' + time_day;
? ? ? this.starttime = this.nowtime;
? ? ? this.endtime = this.nowtime;
? ? },
? ? computed: {},
?
? ? methods: {
?
? ? ? Draw: function (Year, Month) {
?
? ? ? ? //日期列表
? ? ? ? var calendar = [];
?
? ? ? ? //用當(dāng)月第一天在一周中的日期值作為當(dāng)月離第一天的天數(shù)(獲取當(dāng)月第一天是周幾)
? ? ? ? for (var i = 1, firstDay = new Date(Year, Month - 1, 1).getDay(); i <= firstDay; i++) {
? ? ? ? ? ?calendar.push("");
? ? ? ? }
?
? ? ? ? //用當(dāng)月最后一天在一個(gè)月中的日期值作為當(dāng)月的天數(shù)
? ? ? ? for (var i = 1, monthDay = new Date(Year, Month, 0).getDate(); i <= monthDay; i++) {
?
? ? ? ? ? let time_month = Month;
? ? ? ? ? let time_day = i;
? ? ? ? ? if (Month < 10) {
? ? ? ? ? ? time_month = 0 + '' + Month;
? ? ? ? ? }
? ? ? ? ? if (i < 10) {
? ? ? ? ? ? time_day = 0 + '' + i;
? ? ? ? ? }
?
? ? ? ? ? calendar.push({
? ? ? ? ? ? value: i,
? ? ? ? ? ? count: Year + '' + time_month + '' + time_day
? ? ? ? ? })
? ? ? ? }
? ? ? ? this.calendarList = calendar;
? ? ? ? // console.log(calendar)
? ? ? },
?
? ? ? last() {
? ? ? ? this.month--;
? ? ? ? if (this.month == 0) {
? ? ? ? ? this.month = 12;
? ? ? ? ? this.Year--;
? ? ? ? }
?
? ? ? ? this.Draw(this.Year, this.month);
? ? ? },
?
? ? ? next() {
? ? ? ? this.month++;
? ? ? ? if (this.month == 13) {
? ? ? ? ? this.month = 1;
? ? ? ? ? this.Year++;
? ? ? ? }
?
? ? ? ? this.Draw(this.Year, this.month);
? ? ? },
?
?
? ? ? click(item) {
? ? ? ? this.clickcount++;
? ? ? ? this.clickitem = item;
?
? ? ? ? //開始日期
? ? ? ? if (this.clickcount % 2 == 1) {
? ? ? ? ? this.starttime = this.clickitem;
? ? ? ? ? this.endtime = ''
? ? ? ? } else {
? ? ? ? ? this.endtime = this.clickitem;
? ? ? ? ? if (this.starttime > this.endtime) {
? ? ? ? ? ? this.endtime = this.starttime;
? ? ? ? ? ? this.starttime = this.clickitem;
? ? ? ? ? }
? ? ? ? }
? ? ? },
?
?
? ? ? firm(){
?
? ? ? },
?
? ? ? cancle(){
? ? ? this.starttime = this.nowtime;
? ? ? this.endtime = this.nowtime;
? ? ? }
?
? ? }
?
? }
?
</script>
?
<style scoped lang="scss">
? @import "../common/common";
?
? .wrap {
? ? width: 7.5rem;
? ? height: auto;
? ? overflow: hidden;
? ? padding-bottom: 1rem;
? }
?
? .span {
? ? width: 1.07142rem;
? ? height: 0.6rem;
? ? background: #fff;
? ? color: #337ab7;
? ? float: left;
? ? text-align: center;
? ? line-height: 0.6rem;
?
? ? &.active {
? ? ? background: #037ef5;
? ? ? color: #fff;
? ? }
?
? ? &.noclick {
? ? ? pointer-events: none;
? ? ? background: #ccc;
? ? }
?
? ? &.kong {
? ? ? background: #fff;
? ? ? pointer-events: none;
? ? }
? }
?
? .mobile-top {
? ? display: flex;
? ? flex-wrap: nowrap;
? ? background: #fff;
? ? padding: 0.1rem 0;
? ? .sel-time {
? ? ? text-align: center;
? ? ? width: 50%;
? ? ? // border-bottom: solid 2px #2a81e8;
? ? ? .start-date{
? ? ? ? color: #b1b1b1;
? ? ? ? margin-top: 0.05rem;
? ? ? }
? ? }
?
? ? .unsel-time {
? ? ? text-align: center;
? ? ? width: 50%;
? ? ? .end-date{
? ? ? ? color: #b1b1b1;
? ? ? ? ?margin-top: 0.05rem;
? ? ? }
? ? }
? }
?
? .title{
? ? width: 100%;
? ? height: 40px;
? ? background-color: #60a7e8;
? ? display: flex;
? ? flex-wrap: nowrap;
? ? text-align: center;
? ? color: #fff;
? ? font-weight: bold;
? ? line-height: 40px;
?
? ? .btn{
? ? ? width: 1.2rem; ??
? ? ? &.noclick{
? ? ? ? pointer-events: none;
? ? ? ? ?background: #ccc;
? ? ? }
? ? }
? ? .text{
? ? ? flex: 1;
? ? }
? }
?
? .head{
? display: flex;
? flex-wrap: nowrap;
? text-align: center;
? height: 40px;
? line-height: 40px;
? .days{
? ? flex: 1;
? }
? }
?
?
?
? .bottombtn {
? ? height: 40px;
? ? width: 100%;
? ? display: flex;
? ? flex-wrap: nowrap;
?
? ? button {
? ? ? flex: 1;
? ? }
?
? ? .sure-btn {
? ? ? background: #037ef5;
?
? ? ? color: #fff;
? ? }
? }
?
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue使用vant實(shí)現(xiàn)日期選擇器功能

    Vue使用vant實(shí)現(xiàn)日期選擇器功能

    在當(dāng)今前端開發(fā)的領(lǐng)域中,Vue 框架因其高效和靈活的特性備受開發(fā)者青睞,而 Vant 是一個(gè)輕量的移動(dòng)端組件庫,為 Vue 應(yīng)用的開發(fā)提供了豐富且便捷的功能組件,本文將就如何在 Vue 框架中通過 Vant 來實(shí)現(xiàn)日期選擇器的使用,需要的朋友可以參考下
    2024-08-08
  • vue+element-ui+axios實(shí)現(xiàn)圖片上傳

    vue+element-ui+axios實(shí)現(xiàn)圖片上傳

    這篇文章主要為大家詳細(xì)介紹了vue+element-ui+axios實(shí)現(xiàn)圖片上傳,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08
  • 解決Vue.js 2.0 有時(shí)雙向綁定img src屬性失敗的問題

    解決Vue.js 2.0 有時(shí)雙向綁定img src屬性失敗的問題

    下面小編就為大家分享一篇解決Vue.js 2.0 有時(shí)雙向綁定img src屬性失敗的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue前端靈活改變后端地址兩種方式

    vue前端靈活改變后端地址兩種方式

    最近在學(xué)習(xí)或工作中遇到,把Vue前端項(xiàng)目打包后,要求可以再次修改請(qǐng)求后端接口的基礎(chǔ)地址,下面這篇文章主要給大家介紹了關(guān)于vue前端靈活改變后端地址的兩種方式,需要的朋友可以參考下
    2024-03-03
  • 解析Vue.js中的組件

    解析Vue.js中的組件

    組件(Component)是 Vue.js 最強(qiáng)大的功能之一。組件可以擴(kuò)展 HTML 元素,封裝可重用的代碼。這篇文章主要介紹了vue.js 中的組件,需要的朋友參考下
    2018-02-02
  • vue給input file綁定函數(shù)獲取當(dāng)前上傳的對(duì)象完美實(shí)現(xiàn)方法

    vue給input file綁定函數(shù)獲取當(dāng)前上傳的對(duì)象完美實(shí)現(xiàn)方法

    這篇文章主要介紹了vue給input file綁定函數(shù)獲取當(dāng)前上傳的對(duì)象完美實(shí)現(xiàn)方法,需要的朋友可以參考下
    2017-12-12
  • vue模塊拖拽實(shí)現(xiàn)示例代碼

    vue模塊拖拽實(shí)現(xiàn)示例代碼

    這篇文章主要介紹了vue模塊拖拽實(shí)現(xiàn)示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • 關(guān)于vue項(xiàng)目vue-cli-service啟動(dòng)報(bào)錯(cuò)失敗問題的解決方法

    關(guān)于vue項(xiàng)目vue-cli-service啟動(dòng)報(bào)錯(cuò)失敗問題的解決方法

    前端拉取代碼后,想要運(yùn)行代碼的時(shí)候可以能遇到啟動(dòng)報(bào)錯(cuò)的問題,這里我們只針對(duì)于vue-cli-service報(bào)錯(cuò)項(xiàng)來說,文中通過圖文結(jié)合的方式給大家介紹的非常詳細(xì),具有一定的參考價(jià)值,需要的朋友可以參考下
    2024-08-08
  • uniapp模仿微信實(shí)現(xiàn)聊天界面的示例代碼

    uniapp模仿微信實(shí)現(xiàn)聊天界面的示例代碼

    這篇文章主要介紹了如何利用uniapp模仿微信,實(shí)現(xiàn)一個(gè)聊天界面。文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Vue有一定的幫助,感興趣的可以了解一下
    2022-01-01
  • Vue自定義組件實(shí)現(xiàn)v-model雙向數(shù)據(jù)綁定的方法

    Vue自定義組件實(shí)現(xiàn)v-model雙向數(shù)據(jù)綁定的方法

    這篇文章主要介紹了Vue自定義組件實(shí)現(xiàn)v-model雙向數(shù)據(jù)綁定的方法,文中通過代碼示例講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-11-11

最新評(píng)論

新津县| 德庆县| 桑植县| 漾濞| 类乌齐县| 肇州县| 新宁县| 牡丹江市| 英德市| 铜梁县| 循化| 剑阁县| 龙川县| 芦溪县| 全椒县| 积石山| 报价| 乌拉特后旗| 龙口市| 扎鲁特旗| 龙胜| 象山县| 阆中市| 怀化市| 朝阳县| 新沂市| 南乐县| 来宾市| 吴川市| 峨眉山市| 嵊州市| 土默特右旗| 东安县| 绥化市| 成武县| 微博| 景东| 万载县| 宿州市| 金塔县| 磴口县|