微信小程序「渲染层网络层错误」解决方法

解决方案:利用bindload判断图片加载完毕,修改状态显示图片

wxml:

1 <view wx:for="{{flash}}">
3     <image src="{{item.loadReady ? item.img : '默认图'}}" bindload="imageLoadReady" data-index="{{index}}" data-key="flash"></image>
5 </view>

js:

1     //图片加载
2     imageLoadReady(e){
3       let th = this;
4       let images = th.data[e.currentTarget.dataset.key];
5       images[e.currentTarget.dataset.index].loadReady = true;
6       th.setData({
7         [e.currentTarget.dataset.key]:images
8       })
9     }

 

posted @ 2022-04-02 11:12  枫落曳  阅读(2678)  评论(0)    收藏  举报