DateTimePickerView Inline date and time picker
Display linked date and time wheels within configured boundaries.
Import
Use <hui-date-time-picker-view> with uni-app easycom. Import public types from @nscode/handy-uni. For ordinary Vue 3, install the preview plugin from @nscode/handy-uni/web and register its components.
Examples
Interact with the controls to see values and event results on the page.
<template>
<view>
<hui-date-time-picker-view
v-model="value"
type="date"
:min="minimum"
:max="maximum"
@update:model-value="event0"
@change="event1"
@pickstart="event2"
@pickend="event3"
/>
<text>{{ value }}</text>
<text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { type DateTimeValue } from '@nscode/handy-uni'
const lastEvent = ref('No event yet')
const describe = (value: unknown) => {
try {
return JSON.stringify(value) ?? String(value)
} catch {
return String(value)
}
}
const value = ref<DateTimeValue>('2026-11-25')
const minimum = new Date(2026, 0, 1)
const maximum = new Date(2027, 11, 31)
const event0 = (arg0: unknown) => {
lastEvent.value = 'update:modelValue' + ': ' + [describe(arg0)].join(', ')
}
const event1 = (arg0: unknown, arg1: unknown) => {
lastEvent.value = 'change' + ': ' + [describe(arg0), describe(arg1)].join(', ')
}
const event2 = () => {
lastEvent.value = 'pickstart'
}
const event3 = () => {
lastEvent.value = 'pickend'
}
</script>
Inline views commit wheel values directly and have no trigger or popup. Use the popup component when cancellation must discard draft changes.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | DateTimeValue | undefined | Controlled value; undefined means omitted. |
defaultValue | DateTimeValue | null | Initial uncontrolled value; ignored in controlled mode. |
type | DateTimePickerType | 'date' | Semantic type or input mode; see the type definition. |
showSeconds | boolean | false | Include seconds in time-related wheels. |
valueFormat | string | — | Committed format; date returns a Date, timestamp returns milliseconds, and other formats return strings. |
format | string | — | Display format used by the trigger. |
min | string | number | Date | — | Minimum selection count or numeric value. |
max | string | number | Date | — | Maximum selection count, numeric value or displayed count. |
minuteStep | number | 1 | Minute step; invalid values fall back to 1. |
disabledDate | ((date: Date) => boolean) | — | disabled Date; see the value type. |
formatter | ((type: DateTimeColumnType, option: { value: number; label: string; }) => string) | — | Format option text in wheel columns. |
itemHeight | number | 44 | Height of each wheel item in px. |
visibleItemCount | number | 5 | Number of visible wheel items. |
loading | boolean | false | Loading state. |
Root attributes: common props. A Boolean default of undefined supports inheritance; explicit false overrides it. Other Boolean props default to false unless listed otherwise.
Events
| Event | Parameters | Description |
|---|---|---|
update:modelValue | (value: DateTimeValue) | Request a controlled value update. |
change | (value: DateTimeValue, ctx: { date: Date; column: number }) | Emitted after the value changes. |
pickstart | () | Reports the corresponding interaction result. |
pickend | () | Reports the corresponding interaction result. |
Slots
| Slot | Parameters | Description |
|---|---|---|
option | { type, option, active } | Custom option region; replaces its fallback content. |
Methods
None.
Types
DateTimePickerViewProps、DateTimePickerType、DateTimeColumnType、DateTimeValue、DateTimePickerViewEmits are available from @nscode/handy-uni.
Platform notes
| Behavior | uni-app H5 | WeChat Mini Program | App-vue | Ordinary Vue 3 Web (preview) |
|---|---|---|---|---|
| Basic interaction | Supported; device checks pending | Supported; device checks pending | Supported; device checks pending | Supported by the web platform adapter |
Follow the smoke checklist. Device evidence is tracked separately; unit tests do not establish device acceptance.