fix(image): fix image not showing error content error (#679)

This commit is contained in:
jeremywu 2020-11-24 20:22:40 +08:00 committed by GitHub
parent 348bb9477e
commit de86098728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,7 @@
<script lang='ts'>
import { defineComponent, computed, ref, onMounted, onBeforeUnmount, watch } from 'vue'
import { defineComponent, computed, ref, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'
import { isString } from '@vue/shared'
import throttle from 'lodash/throttle'
import { useAttrs } from '@element-plus/hooks'
@ -97,7 +97,6 @@ export default defineComponent({
const imgHeight = ref(0)
const showViewer = ref(false)
const container = ref<HTMLElement | null>(null)
const show = ref(props.lazy)
let _scrollContainer = null
let _lazyLoadHandler = null
@ -248,12 +247,12 @@ export default defineComponent({
}
watch(() => props.src, () => {
show.value && loadImage()
loadImage()
})
onMounted(() => {
if (props.lazy) {
setTimeout(() => addLazyLoadListener(), 0)
nextTick(addLazyLoadListener)
} else {
loadImage()
}
@ -277,6 +276,7 @@ export default defineComponent({
clickHandler,
closeViewer,
container,
handleError,
t,
}
},