feat(ImagePreview): add cover slot (#4766)

This commit is contained in:
neverland
2019-10-18 10:30:19 +08:00
committed by GitHub
parent 321905a4b7
commit dc964ac068
6 changed files with 44 additions and 6 deletions

View File

@@ -249,12 +249,20 @@ export default createComponent({
if (this.showIndex) {
return (
<div class={bem('index')}>
{this.slots('index') || `${this.active + 1}/${this.images.length}`}
{this.slots('index') || `${this.active + 1} / ${this.images.length}`}
</div>
);
}
},
genCover() {
const cover = this.slots('cover');
if (cover) {
return <div class={bem('cover')}>{cover}</div>;
}
},
genImages() {
const imageSlots = {
loading: () => <Loading type="spinner" />
@@ -306,6 +314,7 @@ export default createComponent({
<div class={[bem(), this.className]}>
{this.genImages()}
{this.genIndex()}
{this.genCover()}
</div>
</transition>
);