我想实现微信小程序的瀑布流布局。但是我不知道怎么把云数据库里的图片路径提取出来并且计算宽高放进目标数组中。求各位大佬帮帮忙!
data: {
imgData: [{
"imgSrc": "",
"imgWidth": [],
"imgHeight": [],
}],
leftList: [],
rightList: [],
leftHight: 0,
rightHight: 0,
tabbar: {}
},
bindload(e) {
console.log(e);
var width = e.detail.width;
var height = e.detail.height;
var imgSrc = this.data.imgSrc;
var imgWidth = this.data.imgWidth;
var imgHeight = this.data.imgHeight;
console.log("width", width);
console.log("height", height);
this.setData({
width: imgWidth,
height: imgHeight,
})
},
onLoad: function(options) {
app.editTabbar();
const $ = db.command.aggregate
db.collection('shareImgList').aggregate()
.project({
first: $.arrayElemAt(['$fileIDs', 0]),
})
.end().then(res => {
console.log(res)
this.setData({
imgData: res.list
})
})
},