空空如也 空空如也

微信小程序懒加载测试

wxml

<view wx:if="{{list.length==0}}" style="width: 100%;height: 100px; text-align: center;line-height: 100px;color: #bfbfbf;">空空如也</view>
<view  wx:for="{{list}}" wx:key="item">
   <image src="{{arry[index] ? 'http://cdn.lorine.cn/'+list[index].art_logo: ''}}" class="{{arry[index] ?'Action':''}}"></image>
   <view>[{{item.art_author}}]{{item.art_title}} ¥{{item.art_price}}</view>
</view>

wxss

image {
    opacity: 0;
    width: 100%;
    height: 300px;
    transition: opacity 0.4s linear 0.4s;
  }
   
  .Action {
    opacity: 1;
  }

js

 data: {
        list:[],
        id:1,
        damoHeight: '150',//初始高度
        arry: [false, false, false, false],

    },

   
    onPageScroll: function (res) {
        var _this = this;
        var str = parseInt(res.scrollTop / _this.data.damoHeight);
        _this.data.arry[str] = true;
        _this.setData({
          arry: _this.data.arry
        })
      },

    
     //数据
      getList(id){
        
          var token = wx.getStorageSync('token')
          wx.request({
            url: 'http://www.test.com/api/art/list?id='+id+'&token='+token,
            success:res=>{
                var list = res.data.data
                //console.log(list)
                this.setData({
                    list
                })
            }
          })
      },

     
    onLoad: function (options) {
        var id = options.id;
        //console.log(id)
        this.setData({
            id
        })

        this.getList(id)
       
          let _this = this;
          let num = Math.ceil(wx.getSystemInfoSync().windowHeight / 300);
          for (let i = 0; i < num; i++) {
            _this.data.arry[i] = true;
          };
          this.setData({
            arry: _this.data.arry
          })
        

    },

添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值