Page({/**
* 页面的初始数据
*/data:{scrollTop:0,list:[],},/**
* 生命周期函数--监听页面加载
*/onLoad(options){let list =this.getData(10);this.setData({
list
})},color(){this.r = Math.floor(Math.random()*255);this.g = Math.floor(Math.random()*255);this.b = Math.floor(Math.random()*255);return'rgba('+this.r +','+this.g +','+this.b +',0.8)';},getData(num){const{ list }=this.data;let arr =[];for(let i = list.length; i < num + list.length; i++){let color =this.color()
arr.push({id: i +1,
color
});}return arr;},handleClick(){this.setData({scrollTop:0});}})