一.小知识二.例子,配合轮播图使用效果更佳!(如图1)1.wxmlscroll-view scroll-y="true" swiper catchtap="onSwiperTap" autoplay="auto" interval="3000" duration="500" current="{{swiperCurrent}}" bindchange ...
一.小知识
二.例子,配合轮播图使用效果更佳!(如图1)
1.wxml
<scroll-view scroll-y="true"> <swiper catchtap="onSwiperTap" autoplay="auto" interval="3000" duration="500" current="{{swiperCurrent}}" bindchange="swiperChange"> <block wx:for="{{home_pics}}" wx:for-item="image" wx:for-index="index"> <swiper-item> <image src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image> </swiper-item> </block> </swiper>
2.wxss
<span style="font-family:Comic Sans MS;font-size:18px;color:#333333;">.container { box-sizing:border-box; padding:20px; } .previewimg{ float:left; width:45%; height:200px; margin:2%; } .previewimg image{ width:100%; height:100%; }</span>
3.js
使用网络的图
var app = getApp() Page({ data: { imgalist:[ 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1496287851&di=0a26048f586b8521 93cb5026d60c4fad&imgtype=jpg&er=1&src=http%3A%2F%2Fpic.58pic.com%2F58pic%2F12%2F74%2F05%2F99C58PICYck.jpg', 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1495693185413&di=0d0acdebf0f532edd0fcdb7 6265623c5&imgtype=0&src=http%3A%2F%2Fimg1.3lian.com%2Fimg013%2Fv3%2F2%2Fd%2F61.jpg', ]}, /** * 预览图片 */ previewImage: function (e) { var current=e.target.dataset.src; wx.previewImage({ current: current, // 当前显示图片的http链接 urls: this.data.imgalist // 需要预览的图片http链接列表 }) } })
图1
图2
注意:
网上还有说本地图片确实是不可以的,后面通过选取手机相册内的照片,可以预览,前提是在真机上演示。