小程序接入瀑布流

样式

padding: 20upx;
background-color: #f6f6f6;
column-count: 2;
/*分为两列  用于瀑布流*/
column-gap: 20upx;

数据处理

setDataList(newVal) {
    const newList = [].concat(...Array.from(newVal.reduce((total, cur, index) => { //瀑布流处理
        total[index % 2].push(cur)
        return total
    }, {
        0: [],
        1: [],
        length: 2
    })))
    this.setData({
        newList: newList
    })
},

 

posted @ 2024-05-15 16:46  imzhi  阅读(3)  评论(0编辑  收藏  举报