PickerView Inline picker
Display inline wheels and report draft selection while scrolling.
Import
Use <hui-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-picker-view
v-model="value"
:options="options"
@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 PickerValue } 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<PickerValue | PickerValue[] | null>('sh')
const options = [
{ label: '上海 / Shanghai', value: 'sh' },
{ label: '北京 / Beijing', value: 'bj' }
]
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 | PickerValue | PickerValue[] | null | undefined | Controlled value; undefined means omitted. |
defaultValue | PickerValue | PickerValue[] | null | undefined | Initial uncontrolled value; ignored in controlled mode. |
options | Record<string, unknown>[] | — | Option data; takes precedence over the default slot. |
columns | Record<string, unknown>[][] | — | Wheel column data; children defines linked options. |
data | Record<string, unknown>[] | — | Linked options organized by children. |
props | PickerFieldNames | — | Data field-name mapping. |
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: PickerValue | PickerValue[] | null) | Request a controlled value update. |
change | (value: PickerValue | PickerValue[] | null, context: PickerChangeContext & { column: number }) | Emitted after the value changes. |
pickstart | () | Reports the corresponding interaction result. |
pickend | () | Reports the corresponding interaction result. |
Slots
| Slot | Parameters | Description |
|---|---|---|
option | { option, column, index, active } | Custom option region; replaces its fallback content. |
empty | — | Custom empty region; replaces its fallback content. |
Methods
None.
Types
PickerViewProps、PickerValue、PickerFieldNames、PickerChangeContext、PickerViewEmits 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.