lazyShowImg(){
var that = this
let windowHeight = app.globalData.systemInfo.windowHeight
wx.createSelectorQuery().selectAll('.lazy-item').boundingClientRect((ret) => { //获取需要懒加载的节点[统一class]
ret.forEach((item, index) => {
if (item.top <= windowHeight) { //判断是否在显示范围内
/**老写法*/
// that.data.featuredServerList[index].matteres.forEach((i,index)=>{i.lazyShow = true})
// that.setData({featuredServerList:that.data.featuredServerList})
/**字符串写法 */
that.data.featuredServerList[index].matteres.forEach((i,idx)=>{
that.setData({[`featuredServerList[${index}].matteres[${idx}].i`]:true})
})
}
})
}).exec()
},
<!--如果lazyShow = true : 使用自定义的统一灰色图片
如果lazyShow = false : 使用事项中各自的图片 -->
<image src="{{item.lazyShow?item.icon:item.icon2}}"></image>