1.首先在data中对数组对象进行定义

tp:[

{

url: './img/3.png',

name: '11支康乃馨',

},{

url: './img/4.png',

name: '19支红玫瑰',

},{

url: './img/5.png',

name: '20支百合',

},{

url: './img/6.png',

name: '99只红玫瑰'

}

],

2.然后在使用block标签

view style="background:pink;border-left:1px solid white;"

block wx:for="{{tp}}" wx:key="*this"

view style="border-bottom:1px solid white"

image src="{{item.url}}"/image

text style="color:white"{{item.name}}/text

/view

3.即可得到遍历的图片与名字

TAG标签: 微信小程序遍历对象

http://www.xiaochengxub.com/read-105634.html