chore(ImagePreview): fix demo error

This commit is contained in:
chenjiahan 2020-06-22 20:52:58 +08:00
parent bd1279bc7d
commit 489dde2114
2 changed files with 2 additions and 46 deletions

View File

@ -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);
},
},

View File

@ -32,27 +32,6 @@
<template #index>{{ t('index', index) }}</template>
</van-image-preview>
</demo-block>
<demo-block :title="t('swipeToPosition')">
<van-button type="primary" @click="swipeToPosition">
{{ t('swipeToPosition') }}
</van-button>
<van-image-preview
v-model="showPage"
:images="images"
@change="onChange"
ref="imagePreview"
>
<template #index>
<div class="block__wrap">
<div class="block">{{ t('index', index) }}</div>
<div class="block__btn" @click="swipeToSecond">
{{ t('swipeToThird') }}
</div>
</div>
</template>
</van-image-preview>
</demo-block>
</demo-section>
</template>
@ -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);
},
},
};
</script>
@ -144,15 +111,5 @@ export default {
.van-button {
margin-left: @padding-md;
}
.block {
flex: 1;
text-align: center;
&__wrap {
display: flex;
width: 300px;
}
}
}
</style>