小程序接入瀑布流

樣式

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
    })
},

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章