swiper 高度无法auto?
发布于 5 年前 作者 yxu 12269 次浏览 来自 问答

swiper只能固定一个高度或者100%?高度不确定怎么处理?多个标签高度不一致怎么处理?

2 回复

<  swiper wx:for='{{array}}'  style  =  'height:{{ heights[index] || 50 }}px'  >  

      <  swiper-item  >  

          <  view  class  =  'getThisHeight'  >  

            ...这里放自适应内容  

          </  view  >  

      </  swiper-item  >  

</  swiper  >  


justifyHeight:   function  () {  

      let  that =   this  

      let  hs = []  

    wx.createSelectorQuery().selectAll(  '.  getThisHeight  '  ).boundingClientRect(  function  (rects) {  

        rects.forEach((v, i) => {  

            hs[i] = v.height  

        })  

        that.setData({  

            heights: hs,  

        })  

    }).exec()  

},

结论,这就是个没法用的组件!

回到顶部