# Picker
### 介绍
提供多个选项集合供用户选择其中一项。
### 组件重构
> 自 `v3.2.3` 起,@nutui/nutui-taro 中的 Picker 组件不在支持 3D 展示效果。依赖 Taro 版本 `V3.5.6`
### 安装
```javascript
import { createApp } from 'vue';
// vue
import { Picker, Popup, OverLay } from '@nutui/nutui';
// taro
import { Picker, Popup, OverLay } from '@nutui/nutui-taro';
const app = createApp();
app.use(Picker);
app.use(Popup);
app.use(OverLay);
```
### 基础用法
:::demo
```html
{show=true}">
```
:::
### 默认选中项
通过设置 modelValue 实现默认选中项,modelValue 是一个包含每项配置 value 值的数组。
:::demo
```html
{ show = true;}">
```
:::
### 平铺展示
`threeDimensional` 可关闭 3D 滚动效果。
:::demo
```html
{ show = true;}">
```
:::
### 多列展示
columns 属性可以通过二维数组的形式配置多列选择。
:::demo
```html
{show=true}">
```
:::
### 多级联动
使用 columns 属性的 children 字段可以实现选项级联的效果。
:::demo
```html
{show=true}">
```
:::
### 异步获取
在实际开发中,大部分情况 Columns 属性的数据是通过异步方式获取的。
:::demo
```html
{show=true}">
```
:::
### 自定义按钮
Picker 组件在底部和顶部分别设置了插槽,可进行自定义设置
:::demo
```html
{show=true}">
永远有效
```
:::
## API
### Props
| 参数 | 说明 | 类型 | 默认值 |
|--------------|----------------------------------|--------|------------------|
| v-model:value | 默认选中项 | Array | [] |
| v-model:visible | 是否可见 | Boolean | - |
| columns | 对象数组,配置每一列显示的数据 | Array | - |
| title | 设置标题 | String | - |
| cancel-text | 取消按钮文案 | String | 取消 |
| ok-text | 确定按钮文案 | String | 确定 |
| three-dimensional`v3.1.23` | 是否开启3D效果 | Boolean | true |
| swipe-duration`v3.2.2` | 惯性滚动时长 | Number、String | 1000 |
| safe-area-inset-bottom `v3.2.4` | 是否开启 iphone 系列全面屏底部安全区适配,仅当 `position` 为 `bottom` 时有效 | Boolean |`false` |
| show-ok-text `v3.3.1` | 是否展示确定按钮 | Boolean |`true` |
| show-cancel-text `v3.3.1` | 是否展示取消按钮 | Boolean |`true` |
> 注:自 `v3.2.3` 起,在 @nutui/nutui-taro 中,取消 3D 展示效果,`three-dimensional` 废弃。
### Columns 数据结构
| 参数 | 说明 | 类型 | 默认值 |
|--------------|----------------------------------|--------|------------------|
| text | 选项的文字内容 | String|Number | |
| value | 选项对应的值,且唯一 | String|Number | |
| children | 用于级联选项 | Array | - |
| className | 添加额外的类名 | String | |
### Events
| 事件名 | 说明 | 回调参数 |
|--------|----------------|--------------|
| confirm | 点击确定按钮时触发 | { selectedValue, selectedOptions } |
| close | 点击取消按钮时触发 | { selectedValue, selectedOptions } |
| change | 选项发生改变时触发 | { columnIndex, selectedValue, selectedOptions } |
### Slots
| 事件名 | 说明 |
|--------|----------------|
| default | 自定义滑动数据底部区域 |
| top | 自定义滑动数据顶部区域 |