[Improvement] ImagePreview: suppot onClose callback (#1589)

This commit is contained in:
neverland
2018-08-05 17:37:35 +08:00
committed by GitHub
parent 6f6bed4eb9
commit 428cb5059a
5 changed files with 74 additions and 21 deletions
+20 -7
View File
@@ -12,6 +12,8 @@ import { ImagePreview } from 'vant';
#### 基础用法
直接传入图片数组,即可展示图片预览
```javascript
ImagePreview([
'https://img.yzcdn.cn/1.jpg',
@@ -19,17 +21,27 @@ ImagePreview([
]);
```
#### 指定初始位置
#### 传入配置项
通过传入配置对象,可以指定初始图片的位置、监听关闭事件
```javascript
ImagePreview([
'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg'
], 1);
ImagePreview({
images: [
'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg'
],
startPosition: 1,
onClose() {
// do something
}
});
```
#### 手动关闭
通过实例上的 close 方法可以手动关闭图片预览
```javascript
const instance = ImagePreview([
'https://img.yzcdn.cn/1.jpg',
@@ -41,9 +53,10 @@ setTimeout(() => {
}, 1000);
```
### 方法参数
### 配置项
| 参数名 | 说明 | 类型 |
|-----------|-----------|-----------|
| imageUrls | 需要预览的图片 | `Array` |
| images | 需要预览的图片 URL 数组 | `Array` |
| startPosition | 图片预览起始位置索引 | `Number` |
| onClose | 关闭时的回调函数 | `Function` |