swiper 高度无法auto?

发布于 7 年前作者 yxu12414 次浏览最后编辑 7 年前来自 ask

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

2 回复
yangzhang
yangzhang1 楼6 年前

<  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()  

},

gang82
gang822 楼5 年前

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