fix(Image): failed to hide loading when using lazy-load (#10193)
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
|||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
computed,
|
computed,
|
||||||
|
nextTick,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
defineComponent,
|
defineComponent,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
@@ -159,8 +160,17 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onLazyLoaded = ({ el }: { el: HTMLElement }) => {
|
const onLazyLoaded = ({ el }: { el: HTMLElement }) => {
|
||||||
if (el === imageRef.value && loading.value) {
|
const check = () => {
|
||||||
onLoad();
|
if (el === imageRef.value && loading.value) {
|
||||||
|
onLoad();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (imageRef.value) {
|
||||||
|
check();
|
||||||
|
} else {
|
||||||
|
// LazyLoad may trigger loaded event before Image mounted
|
||||||
|
// https://github.com/youzan/vant/issues/10046
|
||||||
|
nextTick(check);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user