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 // @exposed-api
swipeTo(index, options) { swipeTo(index, options) {
if (!this.$refs.swipe) { if (this.$refs.swipe) {
return; this.$refs.swipe.swipeTo(index, options);
} }
this.$refs.swipe.swipeTo(+index, options);
}, },
}, },

View File

@ -32,27 +32,6 @@
<template #index>{{ t('index', index) }}</template> <template #index>{{ t('index', index) }}</template>
</van-image-preview> </van-image-preview>
</demo-block> </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> </demo-section>
</template> </template>
@ -74,8 +53,6 @@ export default {
button3: '异步关闭', button3: '异步关闭',
button4: '展示关闭按钮', button4: '展示关闭按钮',
componentCall: '组件调用', componentCall: '组件调用',
swipeToPosition: '指定滑动位置',
swipeToThird: '前往第三页',
index: (index) => `${index + 1}`, index: (index) => `${index + 1}`,
}, },
'en-US': { 'en-US': {
@ -84,8 +61,6 @@ export default {
button3: 'Async Close', button3: 'Async Close',
button4: 'Show Close Icon', button4: 'Show Close Icon',
componentCall: 'Component Call', componentCall: 'Component Call',
swipeToPosition: 'swipe to position',
swipeToThird: 'swipe to third page',
index: (index) => `Page: ${index}`, index: (index) => `Page: ${index}`,
}, },
}, },
@ -93,7 +68,6 @@ export default {
data() { data() {
return { return {
show: false, show: false,
showPage: false,
images, images,
index: 0, index: 0,
}; };
@ -104,10 +78,6 @@ export default {
this.show = true; this.show = true;
}, },
componentPage() {
this.showPage = true;
},
onChange(index) { onChange(index) {
this.index = index; this.index = index;
}, },
@ -128,9 +98,6 @@ export default {
}, timer); }, timer);
} }
}, },
swipeToSecond() {
this.$refs.imagePreview.swipeTo(2);
},
}, },
}; };
</script> </script>
@ -144,15 +111,5 @@ export default {
.van-button { .van-button {
margin-left: @padding-md; margin-left: @padding-md;
} }
.block {
flex: 1;
text-align: center;
&__wrap {
display: flex;
width: 300px;
}
}
} }
</style> </style>