微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

uniapp实现轮播图功能,实现轮播图案例

地址:https://www.yujianni.top/news/comp_artinfo.html?id=883

uni-app轮播图主要用到swiper滑块视图容器。一般用于左右滑动或上下滑动,比如banner轮播图。

实现案例:

GIF.gif

页面代码

<template>
<!-- 轮播图 -->
                   <view>
                            <view class="page-section swiper">
                                     <view>
                                               <swiper :indicator-dots="indicatorDots" :indicator-color="indicatorColor" :indicator-active-color="indicatorActiveColor" :autoplay="autoplay" :interval="interval" :duration="duration">
                                                        <swiper-item>
                                                                 <view>
                                                                           <image src="/static/banner_01.jpg" mode=""></image>
                                                                 </view>
                                                        </swiper-item>
                                                        <swiper-item>
                                                                 <view>
                                                                           <image src="/static/banner_02.jpg" mode=""></image>
                                                                 </view>
                                                        </swiper-item>
                                                        <swiper-item>
                                                                 <view>
                                                                           <image src="/static/banner_02.jpg" mode=""></image>
                                                                 </view>
                                                        </swiper-item>
                                               </swiper>
                                     </view>
                            </view>
                   </view>
<!-- 轮播图 -->
</template>

Js代码

<script>
         export default {
                   data() {
                            return {
                                     indicatorDots: true,
                                     autoplay: true,
                                     interval: 3000,
                                     duration: 500,
                                     indicatorColor:"#292b40",
                                     indicatorActiveColor: "#ffffff"
                            }
                   },
                   onLoad() {
 
                   },
                   methods: {
 
                   }
         }
</script>

样式代码

<style>
         .banner{ width: 750rpx; height: 422rpx; background-color: #0f0f27;}
         .banner .swiper{width: 750rpx; height: 422rpx !important;}
         .banner .swiper-item{ width: 750rpx; height: 422rpx !important;}
         .banner .swiper-item image{ display: block; width: 750rpx; height:422rpx !important;}
</style>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐