diff --git a/src/image-preview/ImagePreview.js b/src/image-preview/ImagePreview.js index d8917b66c..faa1b995b 100644 --- a/src/image-preview/ImagePreview.js +++ b/src/image-preview/ImagePreview.js @@ -98,9 +98,12 @@ export default createComponent({ watch: { value(val) { - this.setActive(this.startPosition); - - if (!val) { + if (val) { + this.setActive(this.startPosition); + this.$nextTick(() => { + this.$refs.swipe.swipeTo(this.startPosition, { immediate: true }); + }); + } else { this.$emit('close', { index: this.active, url: this.images[this.active] @@ -310,13 +313,13 @@ export default createComponent({ }, render() { - if (!this.value) { + if (!this.shouldRender) { return; } return ( -
+
{this.genImages()} {this.genIndex()} {this.genCover()}