mirror of
https://github.com/xfgryujk/blivechat.git
synced 2025-03-23 16:20:38 +08:00
前端头像加载失败则使用默认头像
This commit is contained in:
parent
0e060e61fa
commit
0e06c4ba24
@ -1,16 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<yt-img-shadow class="no-transition" :height="height" :width="width" style="background-color: transparent;" loaded>
|
<yt-img-shadow class="no-transition" :height="height" :width="width" style="background-color: transparent;" loaded>
|
||||||
<img id="img" class="style-scope yt-img-shadow" alt="" :height="height" :width="width" :src="imgUrl">
|
<img id="img" class="style-scope yt-img-shadow" alt="" :height="height" :width="width" :src="showImgUrl" @error="onLoadError">
|
||||||
</yt-img-shadow>
|
</yt-img-shadow>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {DEFAULT_AVATAR_URL} from '@/api/chat/avatar'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ImgShadow',
|
name: 'ImgShadow',
|
||||||
props: {
|
props: {
|
||||||
imgUrl: String,
|
imgUrl: String,
|
||||||
height: String,
|
height: String,
|
||||||
width: String
|
width: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showImgUrl: this.imgUrl
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
imgUrl(val) {
|
||||||
|
this.showImgUrl = val
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onLoadError() {
|
||||||
|
if (this.showImgUrl !== DEFAULT_AVATAR_URL) {
|
||||||
|
this.showImgUrl = DEFAULT_AVATAR_URL
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user