11<script >
2- import { defineComponent , h , ref } from ' vue'
2+ import { defineComponent , h , ref , watch } from ' vue'
33import miniProgramIconUrl from ' ~/assets/images/wechat/mini-program.svg'
44
55export default defineComponent ({
@@ -19,7 +19,15 @@ export default defineComponent({
1919 setup (props ) {
2020 const fromAvatarImgOk = ref (false )
2121 const fromAvatarImgError = ref (false )
22- const lastFromAvatarUrl = ref (' ' )
22+
23+ watch (
24+ () => String (props .fromAvatar || ' ' ).trim (),
25+ () => {
26+ fromAvatarImgOk .value = false
27+ fromAvatarImgError .value = false
28+ },
29+ { immediate: true }
30+ )
2331
2432 const getFromText = () => {
2533 const raw = String (props .from || ' ' ).trim ()
@@ -47,12 +55,6 @@ export default defineComponent({
4755 const isCoverVariant = ! isMiniProgram && String (props .variant || ' ' ).trim () === ' cover'
4856 const Tag = canNavigate ? ' a' : ' div'
4957
50- if (fromAvatarUrl !== lastFromAvatarUrl .value ) {
51- lastFromAvatarUrl .value = fromAvatarUrl
52- fromAvatarImgOk .value = false
53- fromAvatarImgError .value = false
54- }
55-
5658 const showFromAvatarImg = Boolean (fromAvatarUrl) && ! fromAvatarImgError .value
5759 const showFromAvatarText = (! fromAvatarUrl) || (! fromAvatarImgOk .value )
5860 const fromAvatarStyle = fromAvatarImgOk .value
0 commit comments