小程序轮播图swiper实现

wxml   ---***vertical写上之后一定要是"{{false}}"  直接写"false"会是true,方向一直是垂直

<!--pages/index4/index4.wxml-->
<view class="container">
    <!-- swiper轮播图 -->
    <view class="swiper-container" hover-class="none" hover-stop-propagation="false">
        <swiper class="top-swiper"   indicator-dots="true" autoplay="true"  circular="true" vertical="{{false}}" >
            <block wx:for="{{swiperitems}}">
                <swiper-item class="top_swiper_item" >
                    <image class="swiper-image" src="{{item}}" mode="scaleToFill" ></image>
                </swiper-item>
            </block>
        </swiper>
    </view>

    <!-- 导航按钮 -->
    <view class="bottom-nav" hover-class="none" hover-stop-propagation="false">
        <block wx:for="{{navItems}}">
            <view class="wrap-item {{item.isSplot?'border-all':'border-bottom'}}" hover-class="none" hover-stop-propagation="false">
                <navigator  target="" url="../../pages/{{item.url}}/{{item.url}}" hover-class="navigator-hover" open-type="navigate">
                    {{item.name}}
                </navigator>
            </view>
        </block>
    </view>
</view>

wxss  --- -***page写height:100%属性,否则轮播图height:30%:属性可能不生效,高度为0;

swiper可以自己定义自己的宽度

swiper不能自己定义自己的高度,需要父控件控制/或者由swipe-item控制   

@1 在swiper外加一层view来控制高度显示

@2 控制swiper-item的高度

page {
	height: 100%;
}
.container {
	height: 100%;
	box-sizing: border-box;
	background-color: #f4f4f4;
}
.swiper-container{
    width: 100%;
    height: 30%;
}
.top-swiper{
    height: 100%;
}
.top_swiper_item{
    width: 100%;
}

js  data中代码

 swiperitems: [
      '../../icons/gongke.jpg',
      '../../icons/greenbook.png',
      '../../icons/Wolverine.png'
      // 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值