Image:fix loading="lazy" lazyLoad not work

pull/22879/head
shay-an 2024-05-15 13:35:40 +08:00
parent c345bb453b
commit 899d72159b
1 changed files with 4 additions and 3 deletions

View File

@ -70,7 +70,7 @@
return { return {
loading: true, loading: true,
error: false, error: false,
show: !this.lazy, show: !(this.lazy || this.$attrs.loading === 'lazy'),
imageWidth: 0, imageWidth: 0,
imageHeight: 0, imageHeight: 0,
showViewer: false showViewer: false
@ -120,7 +120,8 @@
}, },
mounted() { mounted() {
if (this.lazy) { // fix https://github.com/ElemeFE/element/issues/22873
if (this.lazy || this.$attrs.loading === 'lazy') {
this.addLazyLoadListener(); this.addLazyLoadListener();
} else { } else {
this.loadImage(); this.loadImage();
@ -128,7 +129,7 @@
}, },
beforeDestroy() { beforeDestroy() {
this.lazy && this.removeLazyLoadListener(); (this.lazy || this.$attrs.loading === 'lazy') && this.removeLazyLoadListener();
}, },
methods: { methods: {