fix(components): lazy image is not work when it changes src (#3189)

This commit is contained in:
zycoJamie 2021-09-05 01:06:19 +08:00 committed by GitHub
parent 2f9cdc74ce
commit c572d5e6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,12 +301,17 @@ export default defineComponent({
emit('switch', val)
}
watch(
() => props.src,
() => {
watch(() => props.src, () => {
if (props.lazy) {
// reset status
loading.value = true
hasLoadError.value = false
removeLazyLoadListener()
nextTick(addLazyLoadListener)
} else {
loadImage()
}
)
})
onMounted(() => {
if (props.lazy) {