[new feature] ImagePreview: add index slot (#3157)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user