zoukankan      html  css  js  c++  java
  • swiper高度自适应

    swiper这个问题一直困扰了我好久,一开始我是以分页的页数来写高度的,但是数据不够的话就会留白,显然是不好的用户体验,然后百度了很多种,选了一种最适合的,把循环的数据用view框起来,然后得到view的高,设置高度,就ok啦

    height: function () {
        var query = wx.createSelectorQuery()
        let _this = this
        query.select('.getHeight').boundingClientRect()
        query.exec(function (res) {
          _this.setData({
            height: res[0].height
          })
        })
      },

    页面:

     
         <view class="page" style="height: {{height}}px;">
    <!-- 列表 --> <view class="getHeight" hover-class="none" hover-stop-propagation="false"> <block wx:for="{{news}}" wx:key='item' data-index="{{index}}" wx:for-item="item"> <view>{{item.title}}</view> </block> </view>
         </view>
  • 相关阅读:
    连续奇数
    50:数根
    38:花生采摘
    素数对
    17:字符串判等
    2702:密码翻译
    27:单词翻转
    15:整理药名
    12:加密的病历单
    09:密码翻译
  • 原文地址:https://www.cnblogs.com/guomouren/p/13203575.html
Copyright © 2011-2022 走看看