docs(swipe-cell): add swipecell example (#2520)

This commit is contained in:
GPPoseidon 2019-12-13 10:29:11 +08:00 committed by rex
parent 045f2b4c03
commit 1d5afac75a
3 changed files with 65 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import Page from '../../common/page';
import Dialog from '../../dist/dialog/dialog';
import Notify from '../../dist/notify/notify';
Page({
onClose(event) {
@ -17,5 +18,22 @@ Page({
});
break;
}
},
onOpen(event) {
const { position, name } = event.detail;
switch (position) {
case 'left':
Notify({
type: 'primary',
message: `${name}${position}部分展示open事件被触发`
});
break;
case 'right':
Notify({
type: 'primary',
message: `${name}${position}部分展示open事件被触发`
});
break;
}
}
});

View File

@ -18,4 +18,15 @@
</van-swipe-cell>
</demo-block>
<demo-block title="主动打开">
<van-swipe-cell id="swipe-cell2" right-width="{{ 65 }}" left-width="{{ 65 }}" name="示例" bind:open="onOpen" >
<view slot="left" class="van-swipe-cell__left">选择</view>
<van-cell-group>
<van-cell title="单元格" value="内容" />
</van-cell-group>
<view slot="right" class="van-swipe-cell__right">删除</view>
</van-swipe-cell>
</demo-block>
<van-dialog id="van-dialog" />
<van-notify id="van-notify" />

View File

@ -57,6 +57,42 @@ Page({
});
```
### 主动打开
```html
<van-swipe-cell id="swipe-cell2" right-width="{{ 65 }}" left-width="{{ 65 }}" name="示例" bind:open="onOpen" >
<view slot="left" class="van-swipe-cell__left">选择</view>
<van-cell-group>
<van-cell title="单元格" value="内容" />
</van-cell-group>
<view slot="right" class="van-swipe-cell__right">删除</view>
</van-swipe-cell>
```
```js
Page({
onOpen(event) {
const { position, name } = event.detail;
switch (position) {
case 'left':
Notify({
type: 'primary',
message: `${name}${position}部分展示open事件被触发`
});
break;
case 'right':
Notify({
type: 'primary',
message: `${name}${position}部分展示open事件被触发`
});
break;
}
}
});
```
## API
### Props