1.0.3 • Published 4 years ago

manniu-picker v1.0.3

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

manniu-picker使用说明

统一弹窗样式墨客地址http://10.241.65.91:8080/app/jE6SYAU6R/storyboard


参数说明

参数说明类型默认值可选值
pickerType弹窗类型Stringpickerpicker:选择器弹窗 timePicker:时间选择器弹窗
show弹窗是否显示Booleanfalsetrue:显示 false:隐藏
valueFormat日期组件返回值格式化String日期格式
pickerOptionsvant Picker组件和DatetimePicker接受的propsObject官方文档或下方pickerOptions说明

日期格式

使用value-format指定绑定值的格式。

默认情况下,组件接受并返回Date对象。以下为可用的部分格式化字串,其余详细请参考moment: |格式|说明|返回值 |:--:|:--:|:--: |YYYY|四位数字完整表示的年份|如:2014 或 2000 |YY |两位数字表示的年份 | 如:14 或 98 |M |数字表示的月份,没有前导零| 1到12 |MM |数字表示的月份,有前导零| 01到12 |MMM |三个字母缩写表示的月份| Jan到Dec |MMMM |月份,完整的文本格式 |January到December |D |月份中的第几天,没有前导零| 1到31 |DD |月份中的第几天,有前导零| 01到31 |d |星期中的第几天,数字表示|0到6,0表示周日,6表示周六 |ddd| 三个字母表示星期中的第几天| Sun到Sat |dddd |星期几,完整的星期文本 |从Sunday到Saturday |HH |小时,24小时制,有前导零| 00到23 |mm |有前导零的分钟数| 00到59

|ss |有前导零的描述| 01到59

pickerOptions说明

参数说明类型默认值
columns对象数组,配置每一列显示的数据Column[][]
title顶部栏标题 string -
confirm-button-text确认按钮文字string确认
cancel-button-text取消按钮文字string取消
value-key选项对象中,选项文字对应的键名stringtext
toolbar-position顶部栏位置,可选值为bottomstringtop
loading是否显示加载状态boolean false
readonly v2.10.5是否为只读状态,只读状态下无法切换选项booleanfalse
show-toolbar是否显示顶部栏booleanfalse
allow-html是否允许选项内容中渲染 HTMLbooleantrue
default-index单列选择时,默认选中项的索引numberstring0
item-height v2.8.6选项高度,支持 px vw rem 单位,默认 pxnumber/string44
visible-item-count可见的选项个数 numberstring6
swipe-duration快速滑动时惯性滚动的时长,单位 msnumber/string1000

参数说明类型默认值
type时间类型,可选值为 date time year-month month-day datehourstringdatetime
title顶部栏标题string''
confirm-button-text确认按钮文字string确认
cancel-button-text取消按钮文字string取消
show-toolbar是否显示顶部栏booleantrue
loading是否显示加载状态booleanfalse
readonly v2.10.5是否为只读状态,只读状态下无法切换选项booleanfalse
filter选项过滤函数(type, vals) => vals-
formatter选项格式化函数(type, val) => val-
columns-order v2.9.2自定义列排序数组, 子项可选值为 year、month、day、hour、minutestring[]-
item-height v2.8.6选项高度,支持 px vw rem 单位,默认 px numberstring44
visible-item-count可见的选项个数numberstring6
swipe-duration快速滑动时惯性滚动的时长,单位ms numberstring1000

日期选择器

<!-- 日期选择器 -->
    <van-field
      v-model="dateTime"
      picker-type="timePicker"
      label="日期选择"
      placeholder="选择日期"
      input-align="right"
      readonly
      @click="handleDateTime"
    />
    <manniu-picker
      picker-type="timePicker"
      value-format="YYYY-MM-DD"
      :show="showDatePicker"
      :picker-options="{title:'日期选择', type: 'date', minDate: new Date(2020, 0, 1), value: new Date(2022, 10, 11) }"
      @cancel="showDatePicker = false"
      @confirm="confirmDatePicker"
    />

    export default {
    data() {
      return {
        dateTime: '',
        showDatePicker: false,
      };
    },
    methods: {
      // 选择日期
      handleDateTime() {
        this.showDatePicker = true;
      },
      // 确认日期选择
      confirmDatePicker(data) {
        this.showDatePicker = false;
        this.dateTime = data;
      }
    }
  };

普通选择器

<!-- 普通选择器 -->
    <van-field
      v-model="value"
      label="普通选择器"
      placeholder="选择"
      input-align="right"
      readonly
      @click="handlePicker"
    />
    <manniu-picker
      picker-type="picker"
      :show="showPicker"
      :picker-options="{title:'普通选择器',columns:columns"
      @cancel="showPicker = false"
      @confirm="confirmPicker"
    />
    export default {
    data() {
      return {
        value: '',
        showPicker: false,
        columns: [{text: '60',children: [{text: '.4'},{text: '.5'}]},
                  {text: '50',children: [{text: '.4'},{text: '.5'}]}]
      };
    },
    methods: {
      // 选择普通选择器
      handlePicker() {
        this.showPicker = true;
      },
      // 确认选择
      confirmPicker(data) {
        this.showPicker = false;
        console.log('data', data);
      }
    },
  };