# Swipe 滑动手势
### 介绍
常用于单元格左滑删除等手势操作
### 安装
``` javascript
import { createApp } from 'vue';
//vue
import { Swipe } from '@nutui/nutui';
//taro
import { Swipe } from '@nutui/nutui-taro';
const app = createApp();
app.use(Swipe);
```
## 代码演示
### 基础用法
``` html
删除
```
### 禁止滑动
``` html
删除
```
### 左右滑动
``` html
选择
删除
收藏
```
### 异步控制
``` html
删除
```
``` typescript
setup() {
const refSwipe = ref();
const checked = ref(false);
const changSwitch = (value: boolean) => {
if (value) {
refSwipe.value?.open('left');
} else {
refSwipe.value?.close();
}
};
const open = (obj: any) => {
console.log(obj);
checked.value = true;
};
const close = () => {
checked.value = false;
};
return { checked, changSwitch, refSwipe, open, close };
}
```
### 自定义
``` html
选择
删除
收藏
```
``` typescript
setup() {
const number = ref(0);
return { number };
}
```
### Props
| 参数 | 说明 | 类型 | 默认值 |
|--------------------------|----------------------|---------|--------|
| name | 唯一标识 | String | - |
| disabled | 是否禁用滑动 | String | false |
| touch-move-prevent-default | 是否阻止滑动事件行为 | boolean | false |
| touch-move-stop-propagation | 是否阻止滑动事件冒泡 | boolean | false |
### Events
| 事件名 | 说明 | 回调参数 |
|--------|------------|------------------------|
| open | 打开时触发 | {type:'left or right'} |
| close | 关闭时触发 | {type:'left or right'} |
### Slots
| 名称 | 说明 |
|---------|--------------|
| left | 左侧滑动内容 |
| default | 自定义内容 |
| right | 右侧滑动内容 |
### 方法
通过 ref 可以获取到 Swipe 实例并调用实例方法。
| 方法名 | 说明 | 参数 |
|--------|------------------|---------------|
| open | 打开单元格侧边栏 | left or right |
| close | 收起单元格侧边栏 | |