[new feature] ImagePreview: add index slot (#3157)

This commit is contained in:
neverland
2019-04-15 20:59:00 +08:00
committed by GitHub
parent 8d1c02cfbd
commit ce4e0cc3e9
6 changed files with 92 additions and 18 deletions
+14 -4
View File
@@ -17,7 +17,10 @@
<van-image-preview
v-model="show"
:images="images"
/>
@change="onChange"
>
<template v-slot:index>{{ $t('index', index) }}</template>
</van-image-preview>
</demo-block>
</demo-section>
</template>
@@ -38,20 +41,23 @@ export default {
button1: '预览图片',
button2: '指定初始位置',
button3: '异步关闭',
componentCall: '组件调用'
componentCall: '组件调用',
index: index => `${index + 1}`
},
'en-US': {
button1: 'Show Images',
button2: 'Custom Start Position',
button3: 'Async Close',
componentCall: 'Component Call'
componentCall: 'Component Call',
index: index => `Page: ${index}`
}
},
data() {
return {
show: false,
images
images,
index: 0
};
},
@@ -60,6 +66,10 @@ export default {
this.show = true;
},
onChange(index) {
this.index = index;
},
showImagePreview(position, timer) {
const instance = ImagePreview({
images,