小程序学习之轮播图显示不全问题

直接上代码

index.js

//index.js
Page({
  data: {
    background: ["http://59.151.121.92:8001/hx-manager/file/banner/x6lEL28CRV7AMFZ0zP5N81280P1035.jpg", "http://59.151.121.92:8001/hx-manager/file/banner/ng6i41IT167p314hd9f28536LScLB2.jpg", "http://59.151.121.92:8001/hx-manager/file/banner/636596Sf8eO65nzewE8nqwVxkYV8ZN.jpg"],
    indicatorDots: true,
    vertical: false,
    autoplay: false,
    interval: 3000,
    duration: 1200,
  },
  onLoad: function () {
    this.setData({
      autoplay: !this.data.autoplay
    })
  }
})

index.wxml

<!--index.wxml-->
<view class="page">
<view>
  <swiper class="swiper_box" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}">
    <block wx:for="{{background}}" wx:key="*this">
      <swiper-item>
        <image src="{{item}}"></image>
      </swiper-item>
    </block>
  </swiper>
</view>
</view>

index.wxss

/**index.wxss**/
.swiper-item{
  width: 100%;
  display: block;
  height: 150px;
}
.swiper_box {
    height: 400rpx;
    width: 100%;
}
swiper-item image {
    height: 100%;
    width: 100%;
    display: inline-block;
    overflow: hidden;
}

关键在这 height: 400rpx; 直接覆盖swiper的高度

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值