🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@thtf/element-datepicker

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thtf/element-datepicker

A quarter selector component based on element-ui

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
3
-40%
Maintainers
3
Weekly downloads
 
Created
Source

基于 Element-UI DatePicker 的季度选择器。

依赖

Vue 2.6.10+

Element-UI 2.15.6+

安装

npm install @thtf/element-datepicker

快速上手

// 使用组件
<template>
  <div id="app">
    <div class="block">
      <span class="demonstration">季度选择</span>
      <date-picker
        v-model="value1"
        clearable
        type="quarter"
        format="yyyy年QQ季度"
        value-format="yyyyQQ"
        placeholder="选择日期"
      />
    </div>
    <div class="block">
      <span class="demonstration">半年选择</span>
      <date-picker
        v-model="value2"
        clearable
        type="halfYear"
        format="yyyy年[BB]半年"
        value-format="yyyyBB"
        placeholder="选择日期"
      />
    </div>
  </div>
</template>

<script>
  import DatePicker from '@thtf/element-datepicker';

  export default {
    name: 'app',
    components: {
      DatePicker,
    },
    data() {
      return {
        value1: '',
        value2: '',
      };
    },
  };
</script>

日期格式

使用format指定输入框的格式;使用value-format指定绑定值的格式。

默认情况下,组件接受并返回Date对象。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:

:::warning 请注意大小写 :::

格式含义备注举例
yyyy2017
B半年不补01
BB半年01
Q不补01
QQ01
[MM]不需要格式化字符使用方括号标识不需要格式化的字符 (如 [A] [MM])MM

属性

参数说明类型可选值默认值
value / v-model绑定值date(DatePicker)
readonly完全只读booleanfalse
disabled禁用booleanfalse
editable文本框可输入booleantrue
clearable是否显示清除按钮booleantrue
size输入框尺寸stringlarge, small, mini
placeholder非范围选择时的占位内容string
type显示类型stringquarter/halfYearquarter
format显示在输入框中的格式string日期格式yyyy-MM-dd
align对齐方式stringleft, center, rightleft
popper-classDatePicker 下拉框的类名string
default-value可选,选择器打开时默认显示的时间Date可被new Date()解析
value-format可选,绑定值的格式。不指定则绑定值为 Date 对象string日期格式
name原生属性string
prefix-icon自定义头部图标的类名stringel-icon-date
clear-icon自定义清空图标的类名stringel-icon-circle-close
validate-event输入时是否触发表单的校验boolean-true

事件

事件名称说明回调参数
change用户确认选定的值时触发组件绑定值。格式与绑定值一致,可受 value-format 控制
blur当 input 失去焦点时触发组件实例
focus当 input 获得焦点时触发组件实例

方法

方法名说明参数
focus使 input 获取焦点

Keywords

vue

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts