小程序-广告轮播/控制属性

【转】小程序-广告轮播/控制属性

微信小程序广告轮播元素<swiper></swiper>  图片所在元素<swiper-item>/swiper-item>

其中属性有:

 autoplay:true,//是否自动播放
    autoplaytxt:"停止自动播放",
    indicatorDots: true,//指示点
    // indicator-color:"white",//指示点颜色 暂未启动
    // indicator-active-color:"red",//当前选中的指示点颜色暂未启动
    indicatorDotstxt:"隐藏指示灯",
    interval: 1000,//图片切换间隔时间
    duration: 500,//每个图片滑动速度,
    circular:true,//是否采用衔接滑动
    current:3,//初始化时第一个显示的图片 下标值(从0)index

  图片更改事件:bindchange=‘imgchange‘ imagechange()的e.detail.current为当前显示页面的下标值

例子如下:

wxml:

广告轮播/手动滑动 swiper
<swiper bindchange="imgchange" indicatorDots=‘{{indicatorDots}}‘ current=‘{{current}}‘ autoplay=‘{{autoplay}}‘ interval=‘{{interval}}‘duration=‘{{duration}}‘ circular=‘{{circular}}‘>
	<block wx:for=‘{{imgUrls}}‘>
	<swiper-item>
		<image style="" mode="" src="{{item}}" binderror="" bindload="" class=‘swiper-img‘></image>
	</swiper-item>
	</block>
</swiper>
<button  bindtap="autoplaychange" >{{autoplaytxt}}</button>

  wxjs:

Page({
  data: {
    imgUrls: [
      ‘../../img/3.jpg‘,//图片src
      ‘../../img/6.jpg‘,
      ‘../../img/5.jpg‘,
      ‘../../img/4.jpg‘
    ],
    autoplay:true,//是否自动播放
    autoplaytxt:"停止自动播放",
    indicatorDots: true,//指示点
    // indicator-color:"white",//指示点颜色 暂未启动
    // indicator-active-color:"red",//当前选中的指示点颜色暂未启动
    indicatorDotstxt:"隐藏指示灯",
    interval: 1000,//图片切换间隔时间
    duration: 500,//每个图片滑动速度,
    circular:true,//是否采用衔接滑动
    current:3,//初始化时第一个显示的图片 下标值(从0)index

  },
  autoplaychange:function(event){//停止、播放按钮

    if (this.data.autoplaytxt=="停止自动播放") {
      this.setData({
        autoplaytxt:"开始自动播放",
        autoplay:!this.data.autoplay
      })
    }else{
       this.setData({
        autoplaytxt:"停止自动播放",
        autoplay:!this.data.autoplay
      })
    };

  },
  imgchange:function(e){//监听图片改变函数
console.log(e.detail.current)//获取当前显示图片的下标值
  }
})

wxss:  

.swiper-img{
	width: 100%;
	height: 500rpx;
}

  

页面效果:

原文地址:https://www.cnblogs.com/liyuspace/p/8213585.html

时间: 2024-08-03 07:48:45

小程序-广告轮播/控制属性的相关文章

微信小程序的轮播图swiper问题

微信小程序的轮播图swiper,调用后,怎样覆盖系统的 点,达到自己想要的效果 不多说,先上一图望大家多给意见: 这个是效果图: 微信小程序效果图就成这样子: <view class="section section_gap swiper"> <swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}

小程序--swiper轮播图组件

效果图展示: 先了解下swiper组件参数配置 轮播实现的具体步骤如下: 第一步:添加图片素材,我这边是放到images下,文件以及图片名字自定义即可. 第二步:在wxml中进行页面布局 在这里呢,用到了列表渲染.swiper组件,三元运算符(注:由于小程序不能操作dom,三元运算符还有一个常用的使用场景是控件class样式输出,达到jQuery.addClass()的效果) <view class="swiper-container"> <swiper autopl

微信小程序之轮播图

今天记录一下微信小程序开发时,轮播图的效果时怎么实现的.话不多说,直接上代码: <!-- 1. 首页轮播图 --> <view> <swiper class="my-swiper" autoplay="true" indicator-dots="true" indicator-active-color="#fff" circular="true"> <block w

小程序自定义轮播图

话不多说,上图上代码. wxml <view style="white-space: nowrap;" class="box" bindtouchstart="touchstart" bindtouchmove="touchmove" bindtouchend="touchend"> <view class="club" animation="{{animat

如何自定义微信小程序swiper轮播图面板指示点的样式

https://www.cnblogs.com/myboogle/p/6278163.html 微信小程序的swiper组件是滑块视图容器,也就是说平常我们看到的轮播图就可以用它来做,不过这个组件有很多样式是固定的,但是,有时候我们的设计稿的面板指示点是需要个性化的,那么如何去修改swiper组件的面板指示点的样式呢?最近在使用swiper的时候也在想这个,最后发现在调试的时候,可以看到他的选择器.如图: <swiper class="swiper-box" indicator-

自定义微信小程序swiper轮播图面板指示点的样式

微信小程序的swiper组件是滑块视图容器,也就是说平常我们看到的轮播图就可以用它来做,不过这个组件有很多样式是固定的,但是,有时候我们的设计稿的面板指示点是需要个性化的,那么如何去修改swiper组件的面板指示点的样式呢?最近在使用swiper的时候也在想这个,最后发现在调试的时候,可以看到他的选择器.如图: 1 2 3 4 5 6 7 8 9 <swiper class="swiper-box" indicator-dots="{{ indicatordots }}

小程序切换轮播图显示空白的问题

技术栈,taro编译的小程序,场景: 首页几个tab切换,默认第一个tab轮播图有数据,切换的时候后面的轮播图有的时候显示空白,请看: 首先父组件到子组件的值传过来了,自组件img src路径也有值,复制出来地址浏览器,显示没问题,路径问题排除 第一个tab三张轮播图,第二个两张轮播图,其他的tab都是一张,每个tab都从 数组形式传值过来的.有数据这是怎么回事,于是翻翻小郑许官网看到这 https://developers.weixin.qq.com/miniprogram/dev/compo

小程序之轮播图(2020.4.13更新)

wxml <!-- 轮播图 --> <view class='carousel'> <swiper class='carousel_swiper' indicator-dots="true" indicator-color="#f4f4f4" indicator-active-color="#4eb8b8" autoplay="true" interval='5000' circular='tru

小程序开发 轮播

1 2 3