wxml:
<!--pages/index/index.wxml--> <swiper circular="{{circular}}" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="{{indicatorColor}}" indicator-active-color="{{indicatorActiveColor}}"> <block wx:for="{{imgUrls}}"> <swiper-item> <image src="{{item.img_path}}"></image> </swiper-item> </block> </swiper>
js:
// pages/index/index.js Page({ /** * 页面的初始数据 */ data: { circular: true, //是否开启无限轮播,衔接 indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动播放 interval: 3000, //自动切换时间间隔 duration: 1000, //滑动动画时长 indicatorColor: "#eee", //普通轮播点背景色 indicatorActiveColor: "#f10215", //选中轮播点背景色 imgUrls: [{ ‘img_path‘: ‘/images/swiper.png‘ }, { ‘img_path‘: ‘/images/swiper.png‘ }, { ‘img_path‘: ‘/images/swiper.png‘ }, ], }, })