更新记录

1.0.4(2024-07-05)

修复说明文挡上的一个错误

1.0.3(2024-07-05)

优化说明文挡

1.0.2(2024-07-05)

修复开始时间小时有24数字问题 增加开始时间limitStart和结束时间limitEnd配置

查看更多

平台兼容性

HbuilderX/cli最低兼容版本
3.1.0

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios
? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

hbxw-time-range-picker组件

介绍

一个时间段选择器插件如: 15:00:00-16:00:00 / 15时00分00秒-16时00分00秒 / 15:00-16:00 / 15时00分-16时00分

使用示例


<template>
    <view>
        <view>{{result}}</view>
        <button class="button-item" @click="pickerAction0">中文单位的时分秒时间段选择器</button>
        <button class="button-item" @click="pickerAction1">冒号分隔的时分秒时间段选择器</button>
        <button class="button-item" @click="pickerAction2">冒号分隔的时分时间段选择器</button>
        <button class="button-item" @click="pickerAction3">冒号分隔的限制起始和结束的时分秒时间段选择器</button>
        <hbxw-time-range-picker 
            :value="values0" 
            :visible="showPicker0" 
            @change="pickerChange0"
            @cancel="pickerCancel0"
            @sure="pickerSure0"
        />
        <hbxw-time-range-picker 
            :value="values1" 
            :visible="showPicker1"
            :isShowType="false"
            delimiter="point"
            @change="pickerChange1"
            @cancel="pickerCancel1"
            @sure="pickerSure1"
        />
        <hbxw-time-range-picker 
            :value="values2" 
            :visible="showPicker2"
            :isShowType="false"
            delimiter="point"
            :isShowSecond="false"
            @change="pickerChange2"
            @cancel="pickerCancel2"
            @sure="pickerSure2"
        />
        <hbxw-time-range-picker 
            :value="values3" 
            :visible="showPicker3"
            :isShowType="false"
            delimiter="point"
            limitStart="08:08:08"
            limitEnd="22:22:22"
            @change="pickerChange3"
            @cancel="pickerCancel3"
            @sure="pickerSure3"
        />
    </view>
</template>

<script>
    export default {
        data() {
            return {
                showPicker0: false,
                showPicker1: false,
                showPicker2: false,
                showPicker3: false,
                result: null,
                values0: '01时01分01秒-01时01分02秒',
                values1: '08:06:09-08:09:09',
                values2: '08:06-08:09',
                values3: ''
            }
        },
        methods: {
            pickerAction0() {
                this.showPicker0 = true;
            },
            pickerCancel0() {
                this.showPicker0 = false;
            },
            pickerSure0(result) {
                console.log('---- pickerSure0 ----:', result);
                this.result = result;
                this.showPicker0 = false;
            },
            pickerAction1() {
                this.showPicker1 = true;
            },
            pickerCancel1() {
                this.showPicker1 = false;
            },
            pickerSure1(result) {
                console.log('---- pickerSure1 ----:', result);
                this.result = result;
                this.showPicker1 = false;
            },
            pickerAction2() {
                this.showPicker2 = true;
            },
            pickerCancel2() {
                this.showPicker2 = false;
            },
            pickerSure2(result) {
                console.log('---- pickerSure2 ----:', result);
                this.result = result;
                this.showPicker2 = false;
            },
            pickerAction3() {
                this.showPicker3 = true;
            },
            pickerCancel3() {
                this.showPicker3 = false;
            },
            pickerSure3(result) {
                console.log('---- pickerSure3 ----:', result);
                this.result = result;
                this.showPicker3 = false;
            },
            pickerChange0(result) {
                console.log('---- pickerChange0 ----:', result);
                this.result = result;
            },
            pickerChange1(result) {
                console.log('---- pickerChange1 ----:', result);
                this.result = result;
            },
            pickerChange2(result) {
                console.log('---- pickerChange2 ----:', result);
                this.result = result;
            },
            pickerChange3(result) {
                console.log('---- pickerChange3 ----:', result);
                this.result = result;
            }
        }
    }
</script>

<style lang="scss" scoped>
.button-item{
    margin-bottom: 20rpx;
    font-size: 26rpx;
}
</style>

API

Props

属性名 类型 默认值 必填 说明
value Array/String [] 时间段选择的初始值
visible Boolean false 时间段选择器的显示与隐藏
title String 选择时间 时间段选择器标题,如果不需要传空即可
zIndex Number 9999 时间选择器的层级
isShowType Boolean true 是否显示开始时间和结束时间标题
delimiter String 'cn' 时间选择器分隔符格式:cn(时分秒)/point(:)/none(无)
isShowSecond Boolean true 是否要选择到秒,为true则是一个时分秒时间段选择器,如果是false,则上一个时分时间段选择器
limitStart Array/String ['00','00','00'] 时间段选择限制可选开始时间,配置10:10:10 或 10时10分10秒 或者 ['10','10','10']都有效,如果想配置不小于当前时间,可以直接设置为now
limitEnd Array/String ['23','59','59'] 时间段选择限制可选结束时间,配置10:10:10 或 10时10分10秒 或者 ['10','10','10']都有效

Events

事件名 说明 返回值
cancel 点击取消按钮的触发事件 undefined
sure 点击确认按钮的触发事件 举列:{index: Array(6), values: Array(6), valuesStr0: "01时01分01秒-01时01分02秒", valuesStr1: "01:01:01-01:01:02"}
change picker状态发生变化触发事件 举列:{index: Array(6), values: Array(6), valuesStr0: "01时01分01秒-01时01分02秒", valuesStr1: "01:01:01-01:01:02"}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问