Pictures taken from the address of the background, if the network address is incorrect or the picture is not good, not out of the picture page loads will affect the user experience, so it is necessary to show the path when you set about the image loading failure
<img style="width:15%;" :src="xxx" :onerror="defaultSrc">
export default {
data(){
return{
defaultSrc:'this.src="' + require('../assets/img/defaultAvatar.png') + '"',
}
},
}
If direct written
onerror='this.src="' + require('../assets/img/defaultAvatar.png') + '"'
, the page will be insrc
two addresses middle jump back and forth, resulting in a refresh cycle