# miniantpay-swipeaction

> 阿里健康医生支付宝就医助手小程序swipeaction小程序组件

Latest version **0.0.3** (published 2018-12-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install miniantpay-swipeaction
pnpm add miniantpay-swipeaction
yarn add miniantpay-swipeaction
bun add miniantpay-swipeaction
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-12-11 |
| First published | 2018-12-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rick.ls |
| Maintainers | rick.ls |
| Keywords | 阿里健康小程序, 就医助手 |

## Links

- npm: https://www.npmjs.com/package/miniantpay-swipeaction
- npm.io page: https://npm.io/package/miniantpay-swipeaction

## Recent versions

- 0.0.3 (latest) — 2018-12-11
- 0.0.2 — 2018-12-11
- 0.0.1 — 2018-12-07

## README

## SwipeAction 可滑动单元格

可滑动单元格

扫码体验：

<img src="https://gw.alipayobjects.com/zos/rmsportal/AJKkYtCpuwuoaKTQijUB.jpeg" width="154" height="190" />

| 属性名 | 描述 | 类型 | 默认值 |
|----|----|----|----|
|className| 自定义class | String| |
|right| 滑动选项，最多两项 | Array[Object{type: `edit`/`delete`, text: string}]| `[]` |
|onRightItemClick| 点击滑动选项 | function({index, detail, extra, done}) ]| 调用done从而使swipe-action合上 |
| restore | 还原组件到初始状态，当有多个swipe-action组件时，当滑动其中一个时，需要将其他的组件的`restore`属性设置为`true`，避免一个页面同时存在多个swipeAction处于活动状态。 | Boolean | `false` |
| disableSwipe | 是否禁止组件滑动 | Boolean | `false` |


## 示例

```json
{
  "defaultTitle": "SwipeAction",
  "usingComponents": {
    "list": "mini-antui/es/list/index",
    "list-item": "mini-antui/es/list/list-item/index",
    "swipe-action": "mini-antui/es/swipe-action/index"
  }
}
```

```html
<view>
  <list>
    <view a:for="{{list}}" key="{{item.content}}">
      <swipe-action
        index="{{index}}"
        restore="{{swipeIndex === null || swipeIndex !== index}}"
        right="{{item.right}}"
        onRightItemClick="onRightItemClick"
        onSwipeStart="onSwipeStart"
        extra="item{{index}}"
      >
        <list-item
          arrow="horizontal"
          index="{{index}}"
          key="items-{{index}}"
          onClick="onItemClick"
          last="{{index === list.length - 1}}"
        >
          {{item.content}}
        </list-item>
      </swipe-action>
    </view>
  </list>
</view>
```

```javascript
Page({
  data: {
    swipeIndex: null,
    list: [
      { right: [{ type: 'delete', text: '删除' }], content: 'AAA' },
      { right: [{ type: 'edit', text: '取消收藏' }, { type: 'delete', text: '删除' }], content: 'BBB' },
      { right: [{ type: 'delete', text: '删除' }], content: 'CCC' },
    ],
  },
  onRightItemClick(e) {
    const { type } = e.detail;
    my.confirm({
      title: '温馨提示',
      content: `${e.index}-${e.extra}-${JSON.stringify(e.detail)}`,
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      success: (result) => {
        const { list } = this.data;
        if (result.confirm) {
          if (type === 'delete') {
            list.splice(this.data.swipeIndex, 1);
            this.setData({
              list: [...list],
            });
          }

          my.showToast({
            content: '确定 => 执行滑动删除还原',
          });
          e.done();
        } else {
          my.showToast({
            content: '取消 => 滑动删除状态保持不变',
          });
        }
      },
    });
  },
  onItemClick(e) {
    my.alert({
      content: `dada${e.index}`,
    });
  },
  onSwipeStart(e) {
    this.setData({
      swipeIndex: e.index,
    });
  },
});
```

---
_Source: https://npm.io/package/miniantpay-swipeaction · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
