mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Image): failed to hide loading when using lazy-load (#10193)
This commit is contained in:
parent
6e27d02404
commit
be2a401d23
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user