小程序自定义轮播图样式

小程序自定义轮播图样式以下是各案例,仅供大家参考。

效果展示:

index.wxml 代码:

复制代码
<view>
 <!-- 轮播 -->
  <view>
    <swiper indicator-dots="{{indicatorDots}}"
          autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{circular}}" bindchange="swiperChange">
      <block wx:for="{{banner}}">
        <swiper-item>
          <view>
          <image src="{{item.ad_img}}" mode="scaleToFill"></image>
          <view>
          <view>{{item.ad_name}}</view>
          </view>
          </view>
        </swiper-item>
      </block>
    </swiper>
    <view>
      <block wx:for="{{banner}}" wx:key="unique">
        <view class="dot{{index == swiperCurrent ? ' active' : ''}}"></view>
      </block>
    </view>
  </view>
   <!-- 轮播 -->
</view>

index.js 代码:

复制代码
const app = getApp()
 
Page({
  data: {
    now:'',
    banner: [],
    circular: true,
    indicatorDots: false,
    autoplay: true,
    interval: 4000,
    duration: 800,
    swiperCurrent: 0,
  },
  swiperChange(e) {
    let current = e.detail.current;
    // console.log(current, '轮播图')
    let that = this;
    that.setData({
      swiperCurrent: current,
    })
  },
  //事件处理函数
  bindViewTap: function() {
 
  },
  onLoad: function () {
  this.getBanner(); //获取轮播图
  },
    // 轮播
  getBanner:function(){
    var that=this
    wx.request({
      url: app.AppUrl +'/getBanner',
      success(res) {
        that.setData({
          banner: res.data.res_banner,
        })
      }
    })
  },
})

index.wxss 代码:

复制代码
.lunbo{ width: 96%; margin-left: 2%;  height: 350rpx; background: #000; float: left; border-radius: 15rpx; overflow: hidden;position: relative;}
.lunbo swiper{width: 100%; height: 350rpx; }
.lunbo image{ width: 100%; height: 350rpx; display: block; border-radius: 15rpx;}
.lunbo .name{background: linear-gradient(transparent,rgba(0,0,0,.1) 20%,rgba(0,0,0,.2) 35%,rgba(0,0,0,.3) 65%,rgba(0,0,0,.4));
width: 750rpx;
position: absolute;
bottom: -2rpx;
left: 0px;}
.lunbo .name view{
width: 500rpx;
color: #fff;
padding-left: 20rpx;
padding-bottom: 10rpx;
padding-top: 10rpx;
font-size: 30rpx;
 overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
}
.dots{
  position: absolute;
  right: 0;
  bottom: 20rpx;
  display: flex;
}
.dots .dot{
  margin: 0 8rpx;
  width: 8rpx;
  height: 8rpx;
  background:rgba(255,255,255,0.5);
  border-radius: 8rpx;
  transition: all .6s;
}
.dots .dot.active{
  width: 24rpx;
  background: #fff;
}

小程序自定义轮播图样式-遇见你与你分享

相关推荐
智慧景区与市集主理人4 小时前
五一市集分账混乱?巨有科技智慧市集小程序实现统一收款、自动分账
大数据·科技·小程序
程序鉴定师6 小时前
深圳小程序制作哪家好?2026深度市场分析与选择指南?
大数据·小程序
河北清兮网络科技7 小时前
广告联盟全解析:从开发接入到运营优化,多视角拆解流量变现逻辑
小程序·app
张晓℡¹⁸⁰³⁷¹⁸²⁵⁵⁸8 小时前
海外盲盒APP玩法集合,海外盲盒多国语言
小程序·php
互联科技报8 小时前
订货商城选择哪个系统操作更简单?2026小白友好型选型指南
小程序
2501_915921438 小时前
HTTPS前端劫持 新一代流量劫持解决方案
前端·网络协议·ios·小程序·https·uni-app·iphone
智塑未来9 小时前
2026企业数字化观察:小程序定制需求激增,如何避开选型坑?
小程序
肖有米XTKF86469 小时前
二二复制裂变小程序系统制度(双轨制公排模式)
人工智能·小程序·软件工程·团队开发
2601_9579665310 小时前
交友互动式盲盒小程序核心注意事项解析
小程序·小程序开发·盲盒小程序·盲盒系统·盲盒开发
2501_9159090610 小时前
iOS应用签名的三种方法全解析:从官方到第三方工具
android·ios·小程序·https·uni-app·iphone·webview