如何wx:for遍历一个文件夹中所有图片?
想做一个swiper轮播图,在swiper-item前加一个block块用于循环,现有两个问题:
一、有没有更好的思路?
二、block块中如何使用wx:for遍历一个文件夹中所有图片?
我是一个快40岁的小白,请大神勿喷,如有回复请写名具体代码,谢谢啦
6 回复
wxml部分
< swiper indicator-dots = "true" autoplay = "true" interval = "5000" duration = "1000" circular = "true" previous-margin = "50" next-margin = "50" > < block wx:for = "{{imgUrls}}" > < swiper-item > < image src = "{{item.images}}" data-url = "{{item.url}}" bindtap = "onjump" class = "slide-image" width = "355" height = "150" /> </ swiper-item > </ block >
|
js部分
data: { imgUrls: [ { images: 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg' , url: '/pages/index/index' }, { images: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg' , url: '/pages/index/index1' }, { images: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' , url: '/pages/index/index2' } ], }, |
今天刚好给别人写了一个,要熟悉下小程序中for循环的运用