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

Vue2 cube-ui時(shí)間選擇器詳解

 更新時(shí)間:2021年12月20日 16:56:47   作者:貝塔-突突  
這篇文章主要為大家介紹了Vue2 cube-ui時(shí)間選擇器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助

前言

vue2 整合 cube-ui 時(shí)間選擇器(供有點(diǎn)點(diǎn)基礎(chǔ)的看)

一、需求及效果

需求

我們要在原搜索的情況下,加搜索時(shí)間

效果

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

二、代碼實(shí)現(xiàn)

index.vue(html)

<div class="header">
      <cube-input v-on:focus="showMinPicker('startTime')" v-model="startTime" placeholder="開始時(shí)間" :maxlength=30 style="width: 50%;"></cube-input>
      <span>到</span>
      <cube-input v-on:focus="showMinPicker('endTime')" v-model="endTime" placeholder="結(jié)束時(shí)間" :maxlength=30 style="width: 50%;"></cube-input>
</div>

解析:

  • cube-input cube自帶的輸入框。
  • v-on:focus=“showMinPicker(‘startTime')” v-on監(jiān)聽事件,focus指的是輸入框聚焦后觸發(fā)此事件,如果禁用狀態(tài),則不觸發(fā)。
  • v-model 雙向綁定(用于時(shí)間顯示)
  • maxlength 最大長(zhǎng)度

date

data () {
    return {
      // 開始時(shí)間
      startTime: '',
      // 結(jié)束時(shí)間
      endTime: '',
      // 時(shí)間標(biāo)識(shí)
      timeIdentifying: ''
    }
  }

methods

methods: {
    // 監(jiān)聽出發(fā)選擇時(shí)間
    showMinPicker (time) {
      if (!this.minPicker) {
        this.minPicker = this.$createDatePicker({
          title: '選擇時(shí)間',
          visible: true,
          // 最小時(shí)間
          min: new Date(2000, 0, 1),
          // 最大時(shí)間
          max: new Date(2099, 12, 1),
          // 當(dāng)前時(shí)間
          value: new Date(),
          // 顯示的格式
          format: {
            year: 'YYYY',
            month: 'MM',
            date: 'DD'
          },
          // 顯示多少列
          columnCount: 3,
          // 選擇時(shí)間確定后
          onSelect: this.selectHandler,
          // 選擇時(shí)間取消后
          onCancel: this.cancelHandler
        })
      }
      // 選擇時(shí)間標(biāo)識(shí)
      this.timeIdentifying = time
      // 顯示
      this.minPicker.show()
    },
    // 選擇時(shí)間確定后 三個(gè)參數(shù)是不同的時(shí)間格式,可能根據(jù)自己需求定
    selectHandler (selectedTime, selectedText, formatedTime) {
      let time = ''
      for (let index = 0; index < selectedText.length; index++) {
        if (index === (selectedText.length - 1)) {
          time += selectedText[index]
        } else {
          time += selectedText[index] + '-'
        }
      }
      console.log('開始修改')
      if (this.timeIdentifying === 'startTime') {
        console.log('修改startTime')
        this.startTime = time
      } else if (this.timeIdentifying === 'endTime') {
        console.log('修改endTime')
        this.endTime = time
      }
      console.log('結(jié)束修改')
    },
    // 取消事件
    cancelHandler () {
      // 清空選擇好的時(shí)間
      this.startTime = ''
      this.endTime = ''
    }
  }

測(cè)試效果

在這里插入圖片描述

三、資料參考

input

在這里插入圖片描述

TimePicker(時(shí)間選擇器)

在這里插入圖片描述

在這里插入圖片描述

詳細(xì)在官網(wǎng)地址:

官網(wǎng)地址:https://didi.github.io/cube-ui/#/zh-CN

Cube-ui中文文檔地址:https://www.bookstack.cn/read/Cube-UI-zh/30.md

總結(jié)

本篇文章就到這里了,希望能夠給你帶來幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!

相關(guān)文章

最新評(píng)論

濮阳县| 太和县| 达日县| 手游| 包头市| 杭州市| 绥中县| 锦州市| 武清区| 盈江县| 苗栗市| 双峰县| 兴国县| 玉屏| 高台县| 甘孜县| 鹤岗市| 丰台区| 广州市| 翁牛特旗| 和硕县| 镇平县| 和政县| 靖西县| 镶黄旗| 郧西县| 永寿县| 杭州市| 黄梅县| 七台河市| 陆川县| 嘉义市| 抚顺县| 淮滨县| 德昌县| 榆社县| 衡阳县| 宜宾市| 津南区| 宿迁市| 扶沟县|