riverone

微信小程序 官方文档对image 媒体组件加载失败 没有太多的解释,使用中出现了几个小问题,今天抽空记录一下

WXML:

<image class="userinfo-avatar" src="{{avatar}}" binderror="errorFunction"></image>

 

JS:

errorFunction: function(){
    this.setData({
      avatar: \'/image/head.png\'
    })    
}

WXML:

<view wx:for="{{branchList}}" wx:key="{{key}}" wx:for-index=\'index\'>
      <image src=\'{{item.branch_photo}}\' binderror="errorFunction" data-index=\'{{index}}\'></image>
</view>

errorFunction: function (event) {
   console.log(event)
   var index = event.currentTarget.dataset.index
   var img = \'branchList[\'+index+\'].branch_photo\'
     this.setData({
       [img]: \'/pages/resource/img/loading.gif\'
     })   
 }





分类:

技术点:

相关文章:

  • 2021-07-18
  • 2022-01-02
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-04-09
  • 2021-12-25
  • 2021-09-18
  • 2022-12-23
  • 2021-11-17
  • 2021-10-12
  • 2021-06-22
相关资源
相似解决方案