欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue日期選擇框之時間范圍的使用介紹

 更新時間:2022年05月31日 11:03:29   作者:itfallrain  
這篇文章主要介紹了vue日期選擇框之時間范圍的使用,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

vue日期選擇框之時間范圍

實現(xiàn)效果如下

在這里插入圖片描述

 <a-col :xl="8" :lg="16" :md="24" :sm="32">
            <a-form-item label="時間" >
              <a-range-picker
                style="width: 350px"
                v-model="queryParam.createTimeRange"
                :disabled-time="disabledRangeTime"
                :show-time="{
                  hideDisabledOptions: true,
                  defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
                }"
                format="YYYY-MM-DD HH:mm:ss"
                :placeholder="['開始時間', '結(jié)束時間']"
                @change="onDateChange"
                @ok="onDateOk"
              />
            </a-form-item>
          </a-col>

1:引入格式化工具

import moment from 'moment'

2:給默認值

  queryParam:{
            createTimeRange:[
            moment(new Date(new Date(new Date().toLocaleDateString()).getTime()),'YYYY-MM-DD HH:mm:ss'),
            moment(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1),'YYYY-MM-DD HH:mm:ss')
          ]
        },

3:methods書寫的方法

 methods: {
      moment,
      //時間相關(guān)函數(shù) start
      onDateChange: function (value, dateString) {
        console.log(dateString[0],dateString[1]);
        this.queryParam.startTime=dateString[0];
        this.queryParam.endTime=dateString[1];
      },
      onDateOk(value) {
        console.log(value);
      },
      range(start, end) {
        const result = [];
        for (let i = start; i < end; i++) {
          result.push(i);
        }
        return result;
      },
      disabledRangeTime(_, type) {
        if (type === 'start') {
          return {
            disabledHours: () => this.range(0, 60).splice(60, 60),
            disabledMinutes: () => this.range(0, 60).splice(60, 60),
            disabledSeconds: () => this.range(0, 60).splice(60, 60),
          };
        }
        return {
          disabledHours: () => this.range(0, 60).splice(60, 60),
          disabledMinutes: () => this.range(0, 60).splice(60, 60),
          disabledSeconds: () => this.range(0, 60).splice(60, 60),
        };
      },
    //時間相關(guān)函數(shù) end
    }

vue日期控件解析

      <el-form-item label="有效期限" >
        <el-col :span="6">
          <el-form-item>
            <el-date-picker
              type="date"
              placeholder="選擇日期"
              value-format="yyyy-MM-dd 00:00:00"
              v-model="effectiveStartTime"
                :picker-options="pickerOptionsStart"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="6">
          <el-form-item>
            <el-date-picker
              placeholder="選擇日期"
              value-format="yyyy-MM-dd 00:00:00"
              v-model="effectiveEntTime"
                :picker-options="pickerOptionsEnd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item> 

以上template視圖層

    return {
      effectiveEntTime: "",
      effectiveEntTime: "",
      pickerOptionsStart: {
        //開始有效期
        disabledDate: (time) => {
          if (this.effectiveEntTime) {
            return time.getTime() > new Date(this.effectiveEntTime).getTime();
          }
        },
      },
      pickerOptionsEnd: {
        //結(jié)束有效期
        disabledDate: (time) => {
          if (this.effectiveStartTime) {
            return (
              time.getTime() - 3600 * 1000 * 24 <
                new Date(this.effectiveStartTime).getTime() - 86400000 ||
              Date.now() - 3600 * 1000 * 24 > time.getTime()
            );
          }
        },
      },
    };

script 邏輯層

效果

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue3使用echarts繪制折線圖的代碼示例

    vue3使用echarts繪制折線圖的代碼示例

    這篇文章主要為大家學(xué)習(xí)介紹了Vue3如何使用echarts實現(xiàn)繪制折線圖,文中有詳細的示例代碼供大家參考,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-07-07
  • 對類Vue的MVVM前端庫的實現(xiàn)代碼

    對類Vue的MVVM前端庫的實現(xiàn)代碼

    這篇文章主要介紹了對類Vue的MVVM前端庫的實現(xiàn)代碼,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-09-09
  • Vue中的前端crypto.js加解密

    Vue中的前端crypto.js加解密

    這篇文章主要介紹了Vue中的前端crypto.js加解密問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • vue中的Key值重復(fù)問題

    vue中的Key值重復(fù)問題

    這篇文章主要介紹了vue中的Key值重復(fù)問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue.config.js里面的devserver如何配置

    vue.config.js里面的devserver如何配置

    本文介紹了vue.config.js中devServer的常見配置方式,包括基本配置、代理配置、熱模塊替換、靜態(tài)資源服務(wù)、HTTPS配置、多代理配置以及其他配置項,幫助開發(fā)者根據(jù)項目需求進行定制
    2025-01-01
  • 卸載vue2.0并升級vue_cli3.0的實例講解

    卸載vue2.0并升級vue_cli3.0的實例講解

    在本篇文章里小編給大家整理的是關(guān)于卸載vue2.0并升級vue_cli3.0的實例內(nèi)容,需要的朋友們可以學(xué)習(xí)參考下。
    2020-02-02
  • vue中如何覆蓋style中的樣式

    vue中如何覆蓋style中的樣式

    在Vue組件中覆蓋樣式,可以使用更高優(yōu)先級的選擇器、!important或深度選擇器(如::v-deep)來實現(xiàn),選擇合適的方法取決于具體需求
    2025-01-01
  • Vue使用高德地圖選點定位搜索定位功能實現(xiàn)

    Vue使用高德地圖選點定位搜索定位功能實現(xiàn)

    這篇文章主要介紹了Vue使用高德地圖選點定位搜索定位功能,文中給大家提到了常見問題解決方法,本文結(jié)合實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-10-10
  • vue實現(xiàn)簡單圖片上傳功能

    vue實現(xiàn)簡單圖片上傳功能

    這篇文章主要為大家詳細介紹了vue實現(xiàn)簡單圖片上傳功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • vue實現(xiàn)圖書管理demo詳解

    vue實現(xiàn)圖書管理demo詳解

    這篇文章主要介紹了vue實現(xiàn)圖書管理,分享了圖書管理demo用的知識點,以及遇到問題的總結(jié),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-10-10

最新評論