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

Swipe 스와이프

원문 보기 위키 갱신

Swipe는 셀 컴포넌트를 왼쪽·오른쪽으로 밀어서 작업 버튼을 보여주고 싶을 때 쓰는 컴포넌트예요. 목록 항목에서 '삭제', '즐겨찾기' 버튼을 숨겨뒀다가 꺼내 쓰는 패턴이 대표적이죠.

출처: 문서

본문

설치

@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.

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

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

사용 예시

기본 사용법

demo: swipe basic

비활성화

demo: swipe disabled

왼쪽 또는 오른쪽으로 스와이프

demo: swipe direction

Ref 메서드

demo: swipe methods

콘텐츠 커스터마이즈

demo: swipe content

SwipeGroup으로 하나만 열리게 만들기

Swipe의 name prop이 반드시 필요해요.

demo: swipe lock

Swipe

Props

Attribute Description Type Default
name identifies string -
disabled Whether to disabled swipe string false
touch-move-prevent-default Whether to stop touchmove event preventdefault boolean false
touch-move-stop-propagation Whether to stop touchmove event propagation boolean false

Events

Event Description Arguments
click click event name, position: 'left' | 'content' | 'right'
open Emitted when Swipe is opened, swipe left/swipe right name, position: 'left' | 'right'
close Emitted when Swipe is closed, swipe left/swipe right name, position: 'left' | 'right'

Slots

Name Description
left Custom left
default Custom default
right Custom right

Methods

ref로 Swipe 인스턴스를 얻은 뒤 인스턴스 메서드를 호출하세요.

Name Description Arguments
open open swipe, swipe left/swipe right name, position: 'left' | 'right'
close close swipe, swipe left/swipe right name, position: 'left' | 'right'

SwipeGroup

Props

Attribute Description Type Default
lockv4.1.1 When a child Swipe opens, others will close. boolean false

Types v4.3.3

이 컴포넌트는 아래 타입 정의를 함께 내보내요.

import type {
  SwipePosition,
  SwipeProps,
  SwipeInstance,
  SwipeGroupProps,
  SwipeGroupInstance
} from '@nutui/nutui'

더 알아보기 (Learn more)