Skip to content

SwipeAction 滑动操作

通过左右滑动来展示操作按钮,常用于列表项的快捷操作。

基本使用

vue
<script setup lang="ts">
const leftActions = [
  { text: '收藏', background: '#1890ff', width: 70 },
]
const rightActions = [
  { text: '删除', background: '#ee0a24', width: 70 },
  { text: '编辑', background: '#1890ff', width: 70 },
]

const onClick = (action, index, side) => {
  console.log('点击:', action, index, side)
}
</script>

<template>
  <see-swipe-action
    :left-actions="leftActions"
    :right-actions="rightActions"
    @click="onClick"
  >
    <view class="cell-content">
      向左或向右滑动查看操作按钮
    </view>
  </see-swipe-action>
</template>

API

Props

参数名说明类型默认值
leftActions左侧操作按钮SwipeActionItem[][]
rightActions右侧操作按钮SwipeActionItem[][]
isDisabled是否禁用滑动Booleanfalse
threshold触发阈值(按钮宽度比例)Number0.3
swipeWidth滑动宽度(0=自动计算)Number0
isCloseOnClick点击操作按钮后是否自动关闭Booleantrue
isCloseOnTouchOutside触摸外部是否关闭Booleantrue
name标识符(用于分组互斥)String | Number''
isAnimated是否启用回弹动画Booleantrue

SwipeActionItem

参数名说明类型默认值
text按钮文字String-
style按钮样式Object-
background按钮背景色String-
color按钮文字颜色String-
width按钮宽度Number-
icon按钮图标String-
isDisabled是否禁用该按钮Booleanfalse

Events

属性名说明回调参数
onClick点击操作按钮时触发(action: SwipeActionItem, index: number, side: 'left' | 'right')
onOpen滑动打开时触发(side: 'left' | 'right')
onClose关闭时触发-

平台差异

属性微信小程序H5App
leftActions支持支持支持
rightActions支持支持支持
threshold支持支持支持
isAnimated支持支持支持
name(分组互斥)支持支持支持

辽 ICP 备 2025070134 号