uniapp页面元素设置随机颜色
<template v-slot:header>
<view class="uni-ellipsis-1"><span class="clradius" ref="clradius" :style="colorData[index]"></span>文件名称:{{ item.fileName }}</view>
</template>
colorData: []
rgbColor() {
let r = Math.floor(Math.random() * 256);
let g = Math.floor(Math.random() * 256);
let b = Math.floor(Math.random() * 256);
let rgb = `rgb(${r},${g},${b})`;
this.colorData.push("background:" + rgb)
},
this.dataList = this.dataList.concat(res.rows)
this.dataList.forEach(e =>{
this.rgbColor()
})