feat(Uploader): preview-cover slot add index param (#7036)

This commit is contained in:
neverland 2020-08-22 15:48:24 +08:00 committed by GitHub
parent a78a7b6aa8
commit f89f939377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -320,7 +320,11 @@ export default createComponent({
</div>
);
const PreviewCoverContent = this.slots('preview-cover', item);
const PreviewCoverContent = this.slots('preview-cover', {
index,
...item,
});
const PreviewCover = PreviewCoverContent && (
<div class={bem('preview-cover')}>{PreviewCoverContent}</div>
);

View File

@ -76,7 +76,7 @@ exports[`preview-cover slot 1`] = `
<div class="van-image van-uploader__preview-image"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: cover;">
<div class="van-image__loading"><i class="van-icon van-icon-photo van-image__loading-icon">
<!----></i></div>
<div class="van-uploader__preview-cover">https://img.yzcdn.cn/vant/cat.jpeg</div>
<div class="van-uploader__preview-cover">url: https://img.yzcdn.cn/vant/cat.jpeg, index: 0</div>
</div>
<div class="van-uploader__preview-delete"><i class="van-icon van-icon-cross van-uploader__preview-delete-icon">
<!----></i></div>
@ -85,7 +85,7 @@ exports[`preview-cover slot 1`] = `
<div class="van-image van-uploader__preview-image"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: cover;">
<div class="van-image__loading"><i class="van-icon van-icon-photo van-image__loading-icon">
<!----></i></div>
<div class="van-uploader__preview-cover">https://img.yzcdn.cn/vant/cat.jpeg</div>
<div class="van-uploader__preview-cover">url: https://img.yzcdn.cn/vant/cat.jpeg, index: 1</div>
</div>
<div class="van-uploader__preview-delete"><i class="van-icon van-icon-cross van-uploader__preview-delete-icon">
<!----></i></div>

View File

@ -531,7 +531,7 @@ test('preview-cover slot', () => {
fileList: [{ url: IMAGE }, { url: IMAGE }],
},
scopedSlots: {
'preview-cover': (item) => item.url,
'preview-cover': (item) => `url: ${item.url}, index: ${item.index}`,
},
});