HTML:
<view class="content-out" wx:for="{{awardList}}" style="top:{{item.topAward}}rpx;left:{{item.leftAward}}rpx;background-color: {{(index==indexSelect)?colorAwardSelect:colorAwardDefault}};">
<text class="text">{{item.array}}</text>
</view>
JS:
data: {
imageAward: ['1','2','3','4','5','6'],
array:[]
},
onShow:function(){
db.collection("choujiang").get({
success:res=>{
this.setData({
list:res.data[0].name1 ,
array:res.data[0].array
})
console.log(this.data.array+"数据库")
}
})
},
var awardList = [];
var topAward = 25;
var leftAward = 25;
for (var j = 0; j < 6; j++) {
if (j == 0) {
topAward = 25;
leftAward = 25;
} else if (j < 3) {
topAward = topAward;
leftAward = leftAward + 166.6666 + 15;
} else if (j < 5) {
leftAward = leftAward;
topAward = topAward + 150 + 15;
}
var imageAward = this.data.imageAward[j];
var array=this.data.array[j]
console.log(array+"循环遍历")
awardList.push({ topAward: topAward, leftAward: leftAward, imageAward: imageAward,array: array });
}
this.setData({
awardList: awardList
})
},