본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Picker

원문 보기 위키 갱신

Picker (선택기)

화면에서 항목을 골라야 할 때 쓰는 선택기 컴포넌트예요. 보통 Popup 컴포넌트와 함께 사용해요.

출처: 문서

본문

소개

Picker 컴포넌트는 보통 Popup 컴포넌트와 함께 사용해요.

설치

import { createApp } from 'vue'
import { Picker } from '@nutui/nutui'

const app = createApp()
app.use(Picker)

기본 사용법

demo: picker basic

v-model

modelValue를 설정해서 기본 선택을 구현해요. 이 값은 각 설정(column)별 값의 배열이에요.

demo: picker vmodel

Popup과 함께 사용

Picker는 보조 폼 입력으로 채워지는 경우가 많은데, Popup과 짝지어 사용할 수 있어요.

demo: picker popup

3D

demo: picker three-d

여러 컬럼

demo: picker columns

Cascader

Columns 속성의 children 필드를 사용해 옵션을 계층(cascade)으로 연결해요.

demo: picker cascader

비동기

demo: picker async

커스텀 컬럼 필드 v4.1.4

demo: picker field

API

Props

Attribute 설명 Type 기본값
v-model:value 기본 인덱스 Array []
columns 컬럼 데이터 PickerOption[] | PickerOption[][] -
field-namesv4.1.4 커스텀 컬럼 필드 object { text: 'text', value: 'value', children: 'children', className: 'className' }
title 툴바 제목 string -
cancel-text 취소 버튼 텍스트 string cancel
ok-text 확인 버튼 텍스트 string confirm
three-dimensional 3D 효과 켜기 boolean false
swipe-duration 관성 애니메이션 지속 시간 number | string 1000
visible-option-num 보이는 옵션 개수 number | string 7
option-height 옵션 높이 number | string 36
show-toolbar 툴바 표시 여부 boolean true

Events

Event 설명 인자
confirm 확인 버튼을 클릭하면 발생해요. { selectedValue, selectedOptions }
cancel 닫기 버튼을 클릭하면 발생해요. { selectedValue, selectedOptions }
change 현재 옵션이 바뀌면 발생해요. { columnIndex, selectedValue, selectedOptions }

Slots

이름 설명
default 컬럼 아래쪽 콘텐츠 커스텀
top 컬럼 위쪽 콘텐츠 커스텀

PickerOption 데이터 구조

Key 설명 Type 기본값
text 컬럼 텍스트 string | number -
value 컬럼 값 string | number -
children Cascader 옵션 Array -
className 추가 클래스 이름 string -

테마 (Theming)

CSS Variables

컴포넌트는 스타일을 커스터마이즈할 수 있는 CSS 변수를 제공해요. ConfigProvider 컴포넌트를 참고하세요.

이름 기본값
--nut-picker-cancel-color #808080
--nut-picker-ok-color var(--nut-primary-color)
--nut-picker-bar-cancel-font-size 14px
--nut-picker-bar-ok-font-size 14px
--nut-picker-bar-button-padding 0 15px
--nut-picker-bar-title-font-size 16px
--nut-picker-bar-title-color var(--nut-title-color)
--nut-picker-bar-title-font-weight normal
--nut-picker-item-height 36px
--nut-picker-item-text-color var(--nut-title-color)
--nut-picker-item-text-font-size 14px
--nut-picker-item-active-line-border 1px solid #d8d8d8

더 알아보기 (Learn more)