1.单个图片加载失败,用默认图片代替

image src='{{cleanerpicLogo}}' bindload="imageLoad" binderror="imageOnloadError" class='cleanimgs'/image// 加载成功  imageLoad: function (e) {    console.log("imageLoad"+JSON.stringify(e))  },  // 图片加载失败  imageOnloadError(){    console.log("加载图片失败");    this.setData({      cleanerpicLogo:'/assets/images/cleanimgs.png'    })  },

2,列表图片加载失败,用默认图片代替

image src="{{item.serviceProduct.headImgUrl}}" data-index="{{index}}" mode='widthFix' class='tabsimg' binderror="imageOnloadError"/imageimageOnloadError(e) {    console.log(e);    var index = e.currentTarget.dataset.index;    var serviceInfo = this.data.serviceInfo    serviceInfo[index].serviceProduct.headImgUrl = '/assets/images/productdetailimg.png';    this.setData({      serviceInfo: serviceInfo    })  },

 

 

TAG标签: 微信小程序图片加载失败

http://www.xiaochengxub.com/read-103436.html