刚刚接触微信小程序,看着网上的资源写了个小例子,本地图片轮播以及图片上传。
图片轮播:
index.js
var app = getApp() Page({ data:{ mode: 'aspectFit', // src:'../images/timg1.jpg', imgUrls:[ '../images/1.jpg', '../images/2.jpg', '../images/3.jpg', '../images/4.jpg' ], indicatorDots: true, //是否出现焦点 autoplay: true, //是否自动播放 interval: 2000, //自动播放时间间隔 duration: 1000, //滑动动画时间 userInfo: {} }, onLoad:function(){ console.log('onLoad Test'); } }) |
注:imgUrls中为本地图片数组。
index.wxml:
-
<swiper indicator-dots = "{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{imgUrls}}">