[new feature] ImagePreview: add change event (#3155)

This commit is contained in:
neverland 2019-04-15 20:09:42 +08:00 committed by GitHub
parent e8762b2a50
commit 8d1c02cfbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 0 deletions

View File

@ -201,6 +201,7 @@ export default sfc({
onChange(active) {
this.resetScale();
this.active = active;
this.$emit('change', active);
},
resetScale() {

View File

@ -109,6 +109,7 @@ export default {
| Event | Description | Parameters |
|------|------|------|
| close | Triggered when close | { index, url } |
| change | Triggered when current image change | index: index of current image |
### onClose Parematers

View File

@ -37,6 +37,7 @@ test('render image', () => {
expect(wrapper.emitted('input')).toBeFalsy();
triggerDrag(swipe, 0, 0);
expect(wrapper.emitted('input')[0][0]).toBeFalsy();
expect(wrapper.emitted('change')[0][0]).toEqual(2);
});
test('async close', () => {

View File

@ -125,6 +125,7 @@ export default {
| 事件 | 说明 | 回调参数 |
|------|------|------|
| close | 关闭时触发 | { index: 索引, url: 图片链接 } |
| change | 切换当前图片时触发 | index, 当前图片的索引 |
### onClose 回调参数