小程序自定义轮播图样式

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

效果展示:

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;
}

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

相关推荐
I592O9297836 小时前
链动3+1滑落模式小程序开发
小程序
程序员阿龙8 小时前
计算机毕业设计之:基于微信小程序的校园流浪猫收养系统(源码+文档+讲解)
微信小程序·小程序·毕业设计·移动端开发·逍遥游·旅游平台设计·智能旅游系统
Jiaberrr9 小时前
手把手教你:微信小程序实现语音留言功能
前端·微信小程序·小程序·语音·录音
工业互联网专业13 小时前
毕业设计选题:基于ssm+vue+uniapp的驾校预约管理系统小程序
vue.js·小程序·uni-app·毕业设计·ssm·源码·课程设计
V+zmm1013413 小时前
php医院预约挂号系统小程序 LW PPT源码调试讲解
微信小程序·小程序·毕业设计·php·课程设计
赣州云智科技的技术铺子13 小时前
AI运动小程序开发常见问题集锦一
人工智能·微信小程序·小程序
工业互联网专业13 小时前
毕业设计选题:基于ssm+vue+uniapp的面向企事业单位的项目申报小程序
vue.js·小程序·uni-app·毕业设计·ssm·源码·课程设计
cesske15 小时前
小程序与APP的区别
小程序
程序员入门进阶16 小时前
基于微信小程序的购物系统+php(lw+演示+源码+运行)
微信小程序·小程序·php
创意锦囊16 小时前
网页与微信小程序:一场轻量化应用的博弈
微信小程序·小程序