Skip to content

t-picker

Picker 选择器

组件介绍

多列滚动选择器组件,用于选项滚轮选择与结果确认。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

vue
<template>
  <view class="picker-demo">
    <t-picker 
      :columns="3" 
      :rowHeight="50"
      titleKey="name"
      indexKey="id"
      @change="onChange"
      @animationfinish="onAnimationFinish"
    ></t-picker>
  </view>
</template>

<script setup>
function onChange(e) {
  console.log('选择变化:', e);
}

function onAnimationFinish(e) {
  console.log('动画结束:', e);
}
</script>

<style scoped>
.picker-demo {
  padding: 20rpx;
}
</style>

Props

属性名类型默认值说明可选值
columnsNumber3列数-
rowHeightNumber50行高-
titleKeyString"name"显示字段的key-
indexKeyString"id"索引字段的key-

Events

事件名说明回调参数
change选择变化时触发选择结果
animationfinish动画结束时触发-

Methods

方法名说明参数返回值
setData设置选择器数据columnIndex: number, data: Array
getValue获取当前选择值选择结果