Skip to content

SwipeAction 滑动单元格组件

该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作。

温馨提示

本项目参考了 uView-Plus 开源项目的组件开发方式,基于 Vue 3 和 TypeScript 实现了自定义组件。目前该组件仍处于测试阶段。
感谢 uView-Plus 开源项目及其团队成员的贡献,他们的组件开发思路为本项目提供了宝贵地参考。如果需要了解更多组件开发细节,可以参考uView-Plus的 swipeAction组件 的代码实现。

平台差异说明

APP(vue)H5微信小程序

基本使用示例

html
<!-- 全局使用 -->
<hy-swipe-action borderBottom>
    <view class="cell">
        <view class="cell-title">我是标题</view>
        <view class="cell-value">我是内容</view>
    </view>
</hy-swipe-action>

设置左边操作按钮

vue
<template>
    <hy-swipe-action borderBottom>
        <view class="cell">
            <view class="cell-title">我是标题</view>
            <view class="cell-value">我是内容</view>
        </view>
        <template #left>
            <view class="action">
                <view class="action-btn" :style="item.style" v-for="item in options">
                    {{ item.text }}
                </view>
            </view>
        </template>
    </hy-swipe-action>
</template>

<script setup lang="ts">
    const options = [
        {
            text: '收藏',
            style: {
                backgroundColor: '#3c9cff',
            },
        },
        {
            text: '删除',
            style: {
                backgroundColor: '#f56c6c',
            },
        },
    ]
</script>

API

参数说明类型默认值
v-model滑动按钮的状态left|close |rightclose
disabled是否禁用滑动操作booleanfalse
borderBottom显示底部边框booleanfalse
options是否禁用滑动操作booleanfalse
duration动画过渡时间,单位msnumber300
before-close关闭滑动按钮前的钩子函数function-

Events

事件名说明回调参数
click当滑动按钮打开时,点击整个滑动操作容器触发 click 事件event={value}, value 可能为 'left'、'inside'、'right'

Slots

插槽名说明接收值
left自定义左按钮-
default自定义内容-
right自定义右按钮-
10:00