小程序之图片加载失败问题
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 }) },
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

