vue 图片地址加载失败,使用默认图片代替

使用onerror   


computed: {

      defaultAvatar () {

        return 'this.src="'+ require('../assets/img/add.png') +'"'

      }

    },


其中../assets/img/add.png 为加载失败时 显示的默认图片的地址

你可能感兴趣的:(vue 图片地址加载失败,使用默认图片代替)