跳到主要内容

滑动单元格 SwipeCell

可以左右滑动来展示操作按钮的单元格组件。

安装使用

{
// 原生小程序
"usingComponents": {
"ti-swipe-cell": "@titian-design/weapp/swpie-cell/index"
},
// titan-cli搭建的项目
"usingComponents": {
"ti-swipe-cell": "platform://titian-mp/ti-swipe-cell"
}
}

用法示例

基本使用

对于静态内容,组件内部会自动计算宽度

<ti-swipe-cell>
<view>基本模式</view>
<view slot="left">left</view>
<view slot="right">right</view>
</ti-swipe-cell>

自定义左右宽度

备注

自定义宽度的单位为 rpx

<ti-swipe-cell left-width="{{200}}">
<view>自定义左侧宽度</view>
<view slot="left">left</view>
</ti-swipe-cell>

<ti-swipe-cell right-width="{{200}}">
<view>自定义右侧宽度</view>
<view slot="right">right</view>
</ti-swipe-cell>

自动展开

<ti-swipe-cell left-width="{{200}}" visible>
<view>自动展开左侧</view>
<view slot="left">left</view>
</ti-swipe-cell>
<ti-swipe-cell right-width="{{200}}" visible>
<view >自动展开右侧</view>
<view slot="right">right</view>
</ti-swipe-cell>

禁用滑动

<ti-swipe-cell disabled>
<view>禁用滑动</view>
<view slot="left">left</view>
<view slot="right">right</view>
</ti-swipe-cell>

异步操作控制

<ti-button bind:tap="handleClick">控制</ti-button>
<ti-swipe-cell visible="{{visible}}" async-close>
<view>异步控制滑动</view>
<view slot="left">left</view>
</ti-swipe-cell>

监听事件

<ti-swipe-cell bind:open="handleOpen" bind:close="handleClose" bind:click="handleSwipeCellClick">
<view>基本模式</view>
<view slot="left">left</view>
<view slot="right">right</view>
</ti-swipe-cell>

ti-swipe-cell API

属性 Properties

名称类型必填默认值说明备注
left-widthnumber0左边滑动区域宽度-
right-widthnumber0右边滑动区域宽度-
visiblebooleanfalse设置可滑动区域划开会先从左边到右开始查找是否有内容用于展示
disabledbooleanfalse禁止滑动-
async-closebooleanfalse是否异步关闭-
namestring-唯一标识-

事件 Events

事件名参数说明备注
bind:open(e: WechatMiniprogram.CustomEvent<OpenParams>) => void打开时触发-
bind:close(e: WechatMiniprogram.CustomEvent<CloseParams>) => void关闭时触发-
bind:click(e: WechatMiniprogram.CustomEvent<left | right | outside | cell >) => void点击时触发关闭时的点击位置 (left right cell outside)

OpenParams

interface OpenParams {
position: Position;
name: string;
}

CloseParams

interface CloseParams {
position: ClickPosition;
name: string;
instance: TiSwipeCell;
}

插槽 Slots

名称说明备注
right右侧内容-
left左侧内容-

可扩展样式名 External Class

名称说明备注
ext-class根节点可扩展的类名-