/*! For license information please see 7606.f9df5668.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["7606"],{93932:function(s,a,n){"use strict";n.r(a);var t=n("80681");let l=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

SwipeCell

\n

Intro

\n

Used for cell components that can slide left and right to display operation buttons.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

\n
import { createApp } from 'vue';\nimport { SwipeCell } from 'vant';\n\nconst app = createApp();\napp.use(SwipeCell);\n
\n

Usage

\n

Basic Usage

\n
<van-swipe-cell>\n  <template #left>\n    <van-button square type="primary" text="Select" />\n  </template>\n  <van-cell :border="false" title="Cell" value="Cell Content" />\n  <template #right>\n    <van-button square type="danger" text="Delete" />\n    <van-button square type="primary" text="Collect" />\n  </template>\n</van-swipe-cell>\n
\n

Custom Content

\n
<van-swipe-cell>\n  <van-card\n    num="2"\n    price="2.00"\n    desc="Description"\n    title="Title"\n    class="goods-card"\n    thumb="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"\n  />\n  <template #right>\n    <van-button square text="Delete" type="danger" class="delete-button" />\n  </template>\n</van-swipe-cell>\n\n<style>\n  .goods-card {\n    margin: 0;\n    background-color: @white;\n  }\n\n  .delete-button {\n    height: 100%;\n  }\n</style>\n
\n

Before Close

\n
<van-swipe-cell :before-close="beforeClose">\n  <template #left>\n    <van-button square type="primary" text="Select" />\n  </template>\n  <van-cell :border="false" title="Cell" value="Cell Content" />\n  <template #right>\n    <van-button square type="danger" text="Delete" />\n  </template>\n</van-swipe-cell>\n
\n
import { showConfirmDialog } from 'vant';\n\nexport default {\n  setup() {\n    const beforeClose = ({ position }) => {\n      switch (position) {\n        case 'left':\n        case 'cell':\n        case 'outside':\n          return true;\n        case 'right':\n          return new Promise((resolve) => {\n            showConfirmDialog({\n              title: 'Are you sure to delete?',\n            })\n              .then(() => resolve(true))\n              .catch(() => resolve(false));\n          });\n      }\n    };\n\n    return { beforeClose };\n  },\n};\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
nameIdentifier of SwipeCell, usually a unique string or numbernumber | string-
left-widthWidth of the left swipe areanumber | stringauto
right-widthWidth of the right swipe areanumber | stringauto
before-closeCallback function before close(args) => boolean | Promise<boolean>-
disabledWhether to disabled swipebooleanfalse
stop-propagationWhether to stop touchmove event propagationbooleanfalse
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
defaultcustom content
leftcontent of left scrollable area
rightcontent of right scrollable area
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
clickEmitted when SwipeCell is clickedposition: \'left\' | \'right\' | \'cell\' | \'outside\'
openEmitted when SwipeCell is openedvalue: { name: string | number, position: \'left\' | \'right\' }
closeEmitted when SwipeCell is closedvalue: { name: string | number, position: \'left\' | \'right\' | \'cell\' | \'outside\' }
\n

beforeClose Params

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionType
nameNamestring | number
positionClick position\'left\' | \'right\' | \'cell\' | \'outside\'
\n

Methods

\n

Use ref to get SwipeCell instance and call instance methods.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescriptionAttributeReturn value
openopen SwipeCellposition: left | right-
closeclose SwipeCell--
\n

Types

\n

The component exports the following type definitions:

\n
import type {\n  SwipeCellSide,\n  SwipeCellProps,\n  SwipeCellPosition,\n  SwipeCellInstance,\n} from 'vant';\n
\n

SwipeCellInstance is the type of component instance:

\n
import { ref } from 'vue';\nimport type { SwipeCellInstance } from 'vant';\n\nconst swipeCellRef = ref<SwipeCellInstance>();\n\nswipeCellRef.value?.close();\n
\n
'},null,8,l))}}}]);