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"></image>
imageOnloadError(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
    })
  },

 

 

 

相关文章:

  • 2021-04-06
  • 2021-08-21
  • 2021-09-18
  • 2022-12-23
  • 2021-12-23
  • 2021-12-17
  • 2022-12-23
猜你喜欢
  • 2021-10-12
  • 2021-07-18
  • 2021-12-28
  • 2021-04-09
  • 2021-12-16
  • 2021-04-03
  • 2022-12-23
相关资源
相似解决方案