fix(avatar): need reset hasLoadError to false, if src changed (#1515)

This commit is contained in:
pumelo 2021-02-26 21:34:43 +08:00 committed by GitHub
parent f2870e1984
commit 8cdfe1c831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@
</template>
<script lang="ts">
import { defineComponent, computed, ref, PropType } from 'vue'
import { defineComponent, computed, ref, PropType, watch, toRefs } from 'vue'
const ERROR_EVENT = 'error'
export default defineComponent({
@ -50,6 +50,12 @@ export default defineComponent({
setup(props, { emit }) {
const hasLoadError = ref(false)
const { src } = toRefs(props)
// need reset hasLoadError to false if src changed
watch(src,()=>{
hasLoadError.value = false
})
const avatarClass = computed(() => {
const { size, icon, shape } = props
let classList = ['el-avatar']