diff --git a/src/image-preview/ImagePreview.js b/src/image-preview/ImagePreview.js index cce3443a4..0066d7ed8 100644 --- a/src/image-preview/ImagePreview.js +++ b/src/image-preview/ImagePreview.js @@ -408,10 +408,9 @@ export default createComponent({ // @exposed-api swipeTo(index, options) { - if (!this.$refs.swipe) { - return; + if (this.$refs.swipe) { + this.$refs.swipe.swipeTo(index, options); } - this.$refs.swipe.swipeTo(+index, options); }, }, diff --git a/src/image-preview/demo/index.vue b/src/image-preview/demo/index.vue index 23bbf26ff..ec4960fdb 100644 --- a/src/image-preview/demo/index.vue +++ b/src/image-preview/demo/index.vue @@ -32,27 +32,6 @@ {{ t('index', index) }} - - - - {{ t('swipeToPosition') }} - - - - - {{ t('index', index) }} - - {{ t('swipeToThird') }} - - - - - @@ -74,8 +53,6 @@ export default { button3: '异步关闭', button4: '展示关闭按钮', componentCall: '组件调用', - swipeToPosition: '指定滑动位置', - swipeToThird: '前往第三页', index: (index) => `第${index + 1}页`, }, 'en-US': { @@ -84,8 +61,6 @@ export default { button3: 'Async Close', button4: 'Show Close Icon', componentCall: 'Component Call', - swipeToPosition: 'swipe to position', - swipeToThird: 'swipe to third page', index: (index) => `Page: ${index}`, }, }, @@ -93,7 +68,6 @@ export default { data() { return { show: false, - showPage: false, images, index: 0, }; @@ -104,10 +78,6 @@ export default { this.show = true; }, - componentPage() { - this.showPage = true; - }, - onChange(index) { this.index = index; }, @@ -128,9 +98,6 @@ export default { }, timer); } }, - swipeToSecond() { - this.$refs.imagePreview.swipeTo(2); - }, }, }; @@ -144,15 +111,5 @@ export default { .van-button { margin-left: @padding-md; } - - .block { - flex: 1; - text-align: center; - - &__wrap { - display: flex; - width: 300px; - } - } }