3👍
✅
At some point this.form.photo
is an empty string. The browser makes a request to the URL, gets a 404 error, and renders a missing image.
Then the value of this.form.photo
changes, which triggers a rerender, which runs the function again, changes the src
to the new value and renders an actual image.
You need to account for the possibility that this.form.photo
isn’t set.
For example, you could:
getProfilePhoto(){
let photo = "/static/default-profile.png";
if (this.form.photo) {
if (this.form.photo.indexOf('base64') != -1) {
photo = this.form.photo;
} else {
photo = 'storage/profiles/' + this.form.photo;
}
}
return photo;
}
Source:stackexchange.com