头图

渲染有问题:

    <swiper style="height: 300rpx;" indicator-dots="{{true}}" indicator-color="#FFFFFF80" indicator-active-color="#fff" autoplay="{{true}}" interval="{{3000}}" duration="{{500}}">
      <block wx:for="{{list}}" wx:key="index">
        <swiper-item style="border-radius: 16rpx 16rpx 16rpx 16rpx;height: 100%;">
          <view>
            <image src="{{item.fvOssUrl}}" style="width: 100%;height: 300rpx;" mode="aspectFill"></image>
          </view>
        </swiper-item>
      </block>
    </swiper>

微信的官方swiper组件有一个bug,不要在swiper-item上写style样式,否则会造成轮播渲染失败,只显示一张图。

解决方法:
swiper内部要用block嵌套
不要在swiper-item上写style样式
有组件就用组件,这里用的vant的图片组件van-image

    <swiper style="height: 300rpx;" indicator-dots="{{true}}" indicator-color="#FFFFFF80" indicator-active-color="#fff" autoplay="{{true}}" interval="{{3000}}" duration="{{500}}">
      <block wx:for="{{list}}" wx:key="index">
        <swiper-item>
          <view>
            <van-image width="100%" height="300rpx" src="{{item.fvOssUrl}}" />
          </view>
        </swiper-item>
      </block>
    </swiper>

参考:
ios平台部分swiper-item内部的内容无法显示?


兔子先森
420 声望18 粉丝

致力于新技术的推广与优秀技术的普及。